Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to be compatible with older dotnet version #58

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion unity/EzyClientFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ namespace com.tvd12.ezyfoxserver.client.unity
{
public sealed class EzyClientFactory
{
private static readonly EzyClientFactory INSTANCE = new();
private static readonly EzyClientFactory INSTANCE = new EzyClientFactory();

private EzyClientFactory()
{
Expand Down
5 changes: 3 additions & 2 deletions unity/EzyDefaultController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@ public class EzyDefaultController : MonoBehaviour
protected EzySocketProxy socketProxy;
protected EzyAppProxy appProxy;

private readonly List<Object> socketHandlers = new();
private readonly List<Tuple<String, Object>> appHandlers = new();
private readonly List<Object> socketHandlers = new List<Object>();
private readonly List<Tuple<String, Object>> appHandlers =
new List<Tuple<string, Object>>();

protected static readonly EzyLogger LOGGER = EzyUnityLoggerFactory
.getLogger<EzyDefaultController>();
Expand Down
43 changes: 29 additions & 14 deletions unity/EzyEventWSDataDeserializer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@
using System.Collections.Generic;
using com.tvd12.ezyfoxserver.client.constant;
using com.tvd12.ezyfoxserver.client.evt;
using com.tvd12.ezyfoxserver.client.util;
using Newtonsoft.Json;

namespace com.tvd12.ezyfoxserver.client.unity
{
public sealed class EzyEventWSDataDeserializer
{
private static readonly Dictionary<String, EzyEventType>
EVENT_TYPE_BY_STRING_VALUE = new()
EVENT_TYPE_BY_STRING_VALUE = new Dictionary<string, EzyEventType>()
{
{ "CONNECTION_SUCCESS", EzyEventType.CONNECTION_SUCCESS },
{ "CONNECTION_FAILURE", EzyEventType.CONNECTION_FAILURE },
Expand All @@ -19,7 +20,8 @@ private static readonly Dictionary<String, EzyEventType>
};

private static readonly Dictionary<String, EzyConnectionFailedReason>
CONNECTION_FAILED_REASON_BY_STRING_VALUE = new()
CONNECTION_FAILED_REASON_BY_STRING_VALUE =
new Dictionary<string, EzyConnectionFailedReason>()
{
{ "TIME_OUT", EzyConnectionFailedReason.TIME_OUT },
{ "NETWORK_UNREACHABLE", EzyConnectionFailedReason.NETWORK_UNREACHABLE },
Expand All @@ -29,40 +31,53 @@ private static readonly Dictionary<String, EzyConnectionFailedReason>
};

private static readonly Dictionary<EzyEventType, EventDeserializer>
DESERIALIZER_BY_EVENT_TYPE = new()
DESERIALIZER_BY_EVENT_TYPE = new Dictionary<EzyEventType, EventDeserializer>()
{
{ EzyEventType.CONNECTION_SUCCESS, _ => new EzyConnectionSuccessEvent() },
{
EzyEventType.CONNECTION_FAILURE, jsonData => new EzyConnectionFailureEvent(
CONNECTION_FAILED_REASON_BY_STRING_VALUE[
JsonConvert.DeserializeObject<Dictionary<String, String>>(jsonData)
.GetValueOrDefault("reason", "UNKNOWN")
EzyDictionaries.getOrDefault(
JsonConvert.DeserializeObject<Dictionary<String, String>>(jsonData),
"reason",
"UNKNOWN"
)
]
)
},
{
EzyEventType.DISCONNECTION, jsonData => new EzyDisconnectionEvent(
JsonConvert.DeserializeObject<Dictionary<String, int>>(jsonData)
.GetValueOrDefault("reason", 0)
EzyDictionaries.getOrDefault(
JsonConvert.DeserializeObject<Dictionary<String, int>>(jsonData),
"reason",
0
)
)
},
{
EzyEventType.LOST_PING, jsonData => new EzyLostPingEvent(
JsonConvert.DeserializeObject<Dictionary<String, int>>(jsonData)
.GetValueOrDefault("count", 0)
)
EzyDictionaries.getOrDefault(
JsonConvert.DeserializeObject<Dictionary<String, int>>(jsonData),
"count",
0
)
)
},
{
EzyEventType.TRY_CONNECT, jsonData => new EzyTryConnectEvent(
JsonConvert.DeserializeObject<Dictionary<String, int>>(jsonData)
.GetValueOrDefault("count", 0)
)
EzyDictionaries.getOrDefault(
JsonConvert.DeserializeObject<Dictionary<String, int>>(jsonData),
"count",
0
)
)
}
};

private delegate EzyEvent EventDeserializer(String jsonData);

private static readonly EzyEventWSDataDeserializer INSTANCE = new();
private static readonly EzyEventWSDataDeserializer INSTANCE =
new EzyEventWSDataDeserializer();

public static EzyEventWSDataDeserializer getInstance()
{
Expand Down