Updated
This commit is contained in:
@@ -2,12 +2,14 @@
|
||||
// See the LICENSE file or go to https://EonaCat.com/license for full license details.
|
||||
|
||||
using EonaCat.Connections.Models;
|
||||
using EonaCat.Connections.Processors;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
|
||||
namespace EonaCat.Connections.Client.Example
|
||||
{
|
||||
// This file is part of the EonaCat project(s) which is released under the Apache License.
|
||||
// See the LICENSE file or go to https://EonaCat.com/license for full license details.
|
||||
|
||||
public class Program
|
||||
{
|
||||
private const bool UseProcessor = true;
|
||||
@@ -62,7 +64,7 @@ namespace EonaCat.Connections.Client.Example
|
||||
{
|
||||
foreach (var client in _clients)
|
||||
{
|
||||
await client.DisconnectClientAsync().ConfigureAwait(false);
|
||||
await client.DisconnectAsync().ConfigureAwait(false);
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -96,10 +98,9 @@ namespace EonaCat.Connections.Client.Example
|
||||
};
|
||||
processor.OnProcessMessage += (sender, e) =>
|
||||
{
|
||||
WriteToLog($"Processed JSON message from {e.ClientName} ({e.ClientEndpoint}): {e.RawData}");
|
||||
WriteToLog($"Processed JSON message from {e.ClientName} ({e.ClientEndpoint}): {e.Data}");
|
||||
};
|
||||
processor.MaxAllowedBufferSize = 50 * 1024 * 1024; // 10 MB
|
||||
processor.MaxMessagesPerBatch = 5;
|
||||
var json = _jsonContent;
|
||||
|
||||
while (true)
|
||||
@@ -155,7 +156,6 @@ namespace EonaCat.Connections.Client.Example
|
||||
Protocol = ProtocolType.TCP,
|
||||
Host = SERVER_IP,
|
||||
Port = 1111,
|
||||
UseSsl = false,
|
||||
UseAesEncryption = false,
|
||||
EnableHeartbeat = IsHeartBeatEnabled,
|
||||
AesPassword = "EonaCat.Connections.Password",
|
||||
@@ -175,16 +175,11 @@ namespace EonaCat.Connections.Client.Example
|
||||
if (UseProcessor)
|
||||
{
|
||||
_clientsProcessors[client] = new JsonDataProcessor<List<Root>>();
|
||||
_clientsProcessors[client].OnMessageError += (sender, e) =>
|
||||
_clientsProcessors[client].OnError += (sender, e) =>
|
||||
{
|
||||
Console.WriteLine($"Processor error: {e.Message}");
|
||||
};
|
||||
|
||||
_clientsProcessors[client].OnMessageError += (sender, e) =>
|
||||
{
|
||||
Console.WriteLine($"Processor message error: {e.Message}");
|
||||
};
|
||||
|
||||
_clientsProcessors[client].OnProcessTextMessage += (sender, e) =>
|
||||
{
|
||||
Console.WriteLine($"Processed text message from {e.ClientName}: {e.Text}");
|
||||
@@ -192,7 +187,7 @@ namespace EonaCat.Connections.Client.Example
|
||||
|
||||
_clientsProcessors[client].OnProcessMessage += (sender, e) =>
|
||||
{
|
||||
ProcessMessage(e.RawData, e.ClientName, e.ClientEndpoint ?? "Unknown endpoint");
|
||||
ProcessMessage(e.Data, e.ClientName, e.ClientEndpoint ?? "Unknown endpoint");
|
||||
};
|
||||
}
|
||||
|
||||
@@ -200,7 +195,7 @@ namespace EonaCat.Connections.Client.Example
|
||||
{
|
||||
if (UseProcessor)
|
||||
{
|
||||
_clientsProcessors[client].Process(e.StringData, clientName: e.Nickname);
|
||||
_clientsProcessors[client].Process(e.StringData, currentClientName: e.Nickname);
|
||||
return;
|
||||
}
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user