Updated
This commit is contained in:
@@ -20,7 +20,7 @@ namespace EonaCat.Connections.Client.Example
|
||||
//public static string SERVER_IP = "10.40.11.22";
|
||||
public static string SERVER_IP = "127.0.0.1";
|
||||
|
||||
private static Dictionary<NetworkClient, JsonDataProcessor<dynamic>> _clientsProcessors = new Dictionary<NetworkClient, JsonDataProcessor<dynamic>>();
|
||||
private static Dictionary<NetworkClient, JsonDataProcessor<List<Root>>> _clientsProcessors = new Dictionary<NetworkClient, JsonDataProcessor<List<Root>>>();
|
||||
private static bool testDataProcessor;
|
||||
|
||||
public static bool WaitForMessage { get; private set; }
|
||||
@@ -28,9 +28,9 @@ namespace EonaCat.Connections.Client.Example
|
||||
public static bool ToConsoleOnly { get; private set; } = true;
|
||||
public static bool UseJson { get; private set; } = true;
|
||||
public static bool TESTBYTES { get; private set; }
|
||||
public static bool UseJsonProcessorTest { get; private set; } = false;
|
||||
public static bool UseJsonProcessorTest { get; private set; } = true;
|
||||
|
||||
public static async Task Main(string[] args)
|
||||
public static async System.Threading.Tasks.Task Main(string[] args)
|
||||
{
|
||||
for (long i = 0; i < clientCount; i++)
|
||||
{
|
||||
@@ -40,7 +40,7 @@ namespace EonaCat.Connections.Client.Example
|
||||
|
||||
if (testDataProcessor)
|
||||
{
|
||||
_clientsProcessors[client] = new JsonDataProcessor<dynamic>();
|
||||
_clientsProcessors[client] = new JsonDataProcessor<List<Root>>();
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -67,7 +67,7 @@ namespace EonaCat.Connections.Client.Example
|
||||
break;
|
||||
}
|
||||
|
||||
var jsonUrl = "https://samples.json-format.com/employees/json/employees_500KB.json";
|
||||
var jsonUrl = "https://sample.json-format.com/api/download?url=https%3A%2F%2Ffiles.jsons.live%2Femployees%2F5-level%2F20-MB%2Fformatted.json&name=20%20MB%205%20Level%20Formatted.json";
|
||||
|
||||
try
|
||||
{
|
||||
@@ -98,14 +98,16 @@ namespace EonaCat.Connections.Client.Example
|
||||
{
|
||||
WriteToLog($"Processed JSON message from {e.ClientName} ({e.ClientEndpoint}): {e.RawData}");
|
||||
};
|
||||
processor.MaxAllowedBufferSize = 10 * 1024 * 1024; // 10 MB
|
||||
processor.MaxAllowedBufferSize = 50 * 1024 * 1024; // 10 MB
|
||||
processor.MaxMessagesPerBatch = 5;
|
||||
var json = _jsonContent;
|
||||
|
||||
while (true)
|
||||
{
|
||||
json = "TEST1" + _jsonContent + "TEST2";
|
||||
|
||||
processor.Process(json, "TestClient");
|
||||
await Task.Delay(100).ConfigureAwait(false);
|
||||
await System.Threading.Tasks.Task.Delay(100).ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -131,11 +133,11 @@ namespace EonaCat.Connections.Client.Example
|
||||
}
|
||||
}
|
||||
|
||||
await Task.Delay(1000).ConfigureAwait(false);
|
||||
await System.Threading.Tasks.Task.Delay(1000).ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
|
||||
private static async Task StartClientAsync(string clientName, NetworkClient client)
|
||||
private static async System.Threading.Tasks.Task StartClientAsync(string clientName, NetworkClient client)
|
||||
{
|
||||
await client.ConnectAsync().ConfigureAwait(false);
|
||||
|
||||
@@ -157,7 +159,7 @@ namespace EonaCat.Connections.Client.Example
|
||||
UseAesEncryption = false,
|
||||
EnableHeartbeat = IsHeartBeatEnabled,
|
||||
AesPassword = "EonaCat.Connections.Password",
|
||||
Certificate = new System.Security.Cryptography.X509Certificates.X509Certificate2("client.pfx", "p@ss"),
|
||||
//Certificate = new System.Security.Cryptography.X509Certificates.X509Certificate2("client.pfx", "p@ss"),
|
||||
};
|
||||
|
||||
var client = new NetworkClient(config);
|
||||
@@ -172,8 +174,8 @@ namespace EonaCat.Connections.Client.Example
|
||||
|
||||
if (UseProcessor)
|
||||
{
|
||||
_clientsProcessors[client] = new JsonDataProcessor<object>();
|
||||
_clientsProcessors[client].OnError += (sender, e) =>
|
||||
_clientsProcessors[client] = new JsonDataProcessor<List<Root>>();
|
||||
_clientsProcessors[client].OnMessageError += (sender, e) =>
|
||||
{
|
||||
Console.WriteLine($"Processor error: {e.Message}");
|
||||
};
|
||||
@@ -198,7 +200,7 @@ namespace EonaCat.Connections.Client.Example
|
||||
{
|
||||
if (UseProcessor)
|
||||
{
|
||||
_clientsProcessors[client].Process(e, currentClientName: e.Nickname);
|
||||
_clientsProcessors[client].Process(e.StringData, clientName: e.Nickname);
|
||||
return;
|
||||
}
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user