Updated
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
using EonaCat.Connections;
|
||||
using EonaCat.Connections.Models;
|
||||
using System.Text;
|
||||
|
||||
namespace EonaCat.Connections.Client.Example
|
||||
{
|
||||
@@ -7,12 +8,9 @@ namespace EonaCat.Connections.Client.Example
|
||||
{
|
||||
private static NetworkClient _client;
|
||||
|
||||
public static void Main(string[] args)
|
||||
public static async Task Main(string[] args)
|
||||
{
|
||||
for (int i = 0; i < 100000; i++)
|
||||
{
|
||||
CreateClientAsync(i).ConfigureAwait(false);
|
||||
}
|
||||
await CreateClientAsync().ConfigureAwait(false);
|
||||
|
||||
while (true)
|
||||
{
|
||||
@@ -20,27 +18,42 @@ namespace EonaCat.Connections.Client.Example
|
||||
var message = Console.ReadLine();
|
||||
if (!string.IsNullOrEmpty(message) && message.Equals("exit", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
_client.DisconnectAsync().ConfigureAwait(false);
|
||||
await _client.DisconnectAsync().ConfigureAwait(false);
|
||||
break;
|
||||
}
|
||||
|
||||
var jsonUrl = "https://microsoftedge.github.io/Demos/json-dummy-data/5MB-min.json";
|
||||
|
||||
try
|
||||
{
|
||||
using var httpClient = new HttpClient();
|
||||
var jsonContent = await httpClient.GetStringAsync(jsonUrl);
|
||||
var jsonSize = Encoding.UTF8.GetByteCount(jsonContent);
|
||||
Console.WriteLine($"Using large JSON file (size: {jsonSize / 1024 / 1024} MB)");
|
||||
message = jsonContent;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine($"Failed to download large JSON file: {ex.Message}");
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(message))
|
||||
{
|
||||
_client.SendAsync(message).ConfigureAwait(false);
|
||||
await _client.SendAsync(message).ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static async Task CreateClientAsync(int i)
|
||||
private static async Task CreateClientAsync()
|
||||
{
|
||||
var config = new Configuration
|
||||
{
|
||||
Protocol = ProtocolType.TCP,
|
||||
Host = "127.0.0.1",
|
||||
Port = 8080,
|
||||
UseSsl = true,
|
||||
UseAesEncryption = true,
|
||||
ServerCertificate = new System.Security.Cryptography.X509Certificates.X509Certificate2("client.pfx", "p@ss"),
|
||||
Port = 1111,
|
||||
UseSsl = false,
|
||||
UseAesEncryption = false,
|
||||
//ServerCertificate = new System.Security.Cryptography.X509Certificates.X509Certificate2("client.pfx", "p@ss"),
|
||||
};
|
||||
|
||||
_client = new NetworkClient(config);
|
||||
@@ -58,7 +71,7 @@ namespace EonaCat.Connections.Client.Example
|
||||
await _client.ConnectAsync();
|
||||
|
||||
// Send nickname
|
||||
await _client.SendNicknameAsync($"TestUser{i}");
|
||||
await _client.SendNicknameAsync("TestUser");
|
||||
|
||||
// Send a message
|
||||
await _client.SendAsync("Hello server!");
|
||||
|
Reference in New Issue
Block a user