-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #189 from SakulFlee/SakulFlee/issue107
iOS Support
- Loading branch information
Showing
14 changed files
with
125 additions
and
75 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
using System.Text.Json; | ||
using System.Text.Json.Serialization; | ||
using Godot; | ||
|
||
[JsonSourceGenerationOptions( | ||
WriteIndented = true, | ||
PropertyNamingPolicy = JsonKnownNamingPolicy.CamelCase, | ||
IncludeFields = true, | ||
DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull | ||
)] | ||
[JsonSerializable(typeof(ChatMessagePacket))] | ||
public partial class ChatJsonSourceGenContext : JsonSerializerContext | ||
{ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
using System.Text.Json; | ||
|
||
public interface ChatPacketSerializer | ||
{ | ||
/// <summary> | ||
/// Deserializes (/Parse) from JSON | ||
/// </summary> | ||
/// <param name="json">The JSON string to parse</param> | ||
/// <returns>An instance of this T class</returns> | ||
public static T FromJSON<T>(string json) where T : class | ||
{ | ||
return JsonSerializer.Deserialize(json, typeof(T), ChatJsonSourceGenContext.Default) as T; | ||
} | ||
|
||
/// <summary> | ||
/// Serializes this instance to JSON | ||
/// </summary> | ||
/// <returns>This T as JSON</returns> | ||
public static string ToJSON(object o) | ||
{ | ||
return JsonSerializer.Serialize(o, o.GetType(), ChatJsonSourceGenContext.Default); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
using System.Text.Json; | ||
using System.Text.Json.Serialization; | ||
using Godot; | ||
|
||
[JsonSourceGenerationOptions( | ||
WriteIndented = true, | ||
PropertyNamingPolicy = JsonKnownNamingPolicy.CamelCase, | ||
IncludeFields = true, | ||
DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull | ||
)] | ||
[JsonSerializable(typeof(GamePacket))] | ||
[JsonSerializable(typeof(GamePacketInput))] | ||
[JsonSerializable(typeof(GamePacketPlayer))] | ||
[JsonSerializable(typeof(GamePacketType))] | ||
public partial class GameJsonSourceGenContext : JsonSerializerContext | ||
{ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
using System.Text.Json; | ||
|
||
public interface GamePacketSerializer | ||
{ | ||
/// <summary> | ||
/// Deserializes (/Parse) from JSON | ||
/// </summary> | ||
/// <param name="json">The JSON string to parse</param> | ||
/// <returns>An instance of this T class</returns> | ||
public static T FromJSON<T>(string json) where T : class | ||
{ | ||
return JsonSerializer.Deserialize(json, typeof(T), GameJsonSourceGenContext.Default) as T; | ||
} | ||
|
||
/// <summary> | ||
/// Serializes this instance to JSON | ||
/// </summary> | ||
/// <returns>This T as JSON</returns> | ||
public static string ToJSON(object o) | ||
{ | ||
return JsonSerializer.Serialize(o, o.GetType(), GameJsonSourceGenContext.Default); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
using System.Text.Json.Serialization; | ||
|
||
[JsonSourceGenerationOptions( | ||
WriteIndented = true, | ||
PropertyNamingPolicy = JsonKnownNamingPolicy.CamelCase, | ||
IncludeFields = true, | ||
DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull | ||
)] | ||
[JsonSerializable(typeof(MatchMakerResponse))] | ||
[JsonSerializable(typeof(MatchMakerRequest))] | ||
[JsonSerializable(typeof(MatchMakerUpdate))] | ||
[JsonSerializable(typeof(Packet))] | ||
[JsonSerializable(typeof(PacketType))] | ||
public partial class JsonSourceGenContext : JsonSerializerContext | ||
{ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters