Updated
This commit is contained in:
@@ -7,6 +7,14 @@
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Content Remove="C:\Users\jesa\.nuget\packages\eonacat.json\2.0.6\contentFiles\any\net8.0\Monikers.imagemanifest" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="EonaCat.Json" Version="2.2.3" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\EonaCat.Connections\EonaCat.Connections.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
@@ -1,69 +1,72 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace EonaCat.Connections.Client
|
||||
{
|
||||
// Root myDeserializedClass = JsonConvert.DeserializeObject<List<Root>>(myJsonResponse);
|
||||
public class Contact
|
||||
{
|
||||
public string email { get; set; }
|
||||
public string phone { get; set; }
|
||||
}
|
||||
|
||||
public class Department
|
||||
{
|
||||
public string id { get; set; }
|
||||
public string name { get; set; }
|
||||
public Manager manager { get; set; }
|
||||
}
|
||||
|
||||
public class Details
|
||||
{
|
||||
public int hoursSpent { get; set; }
|
||||
public List<string> technologiesUsed { get; set; }
|
||||
public string completionDate { get; set; }
|
||||
public string expectedCompletion { get; set; }
|
||||
}
|
||||
|
||||
public class Employee
|
||||
{
|
||||
public string id { get; set; }
|
||||
public string name { get; set; }
|
||||
public string position { get; set; }
|
||||
public Department department { get; set; }
|
||||
public List<Project> projects { get; set; }
|
||||
}
|
||||
|
||||
public class Manager
|
||||
{
|
||||
public string id { get; set; }
|
||||
public string name { get; set; }
|
||||
public Contact contact { get; set; }
|
||||
}
|
||||
|
||||
public class Project
|
||||
{
|
||||
public string projectId { get; set; }
|
||||
public string projectName { get; set; }
|
||||
public string startDate { get; set; }
|
||||
public List<Task> tasks { get; set; }
|
||||
}
|
||||
|
||||
public class Root
|
||||
{
|
||||
public Employee employee { get; set; }
|
||||
}
|
||||
|
||||
public class Task
|
||||
{
|
||||
public string taskId { get; set; }
|
||||
public string title { get; set; }
|
||||
public string status { get; set; }
|
||||
public Details details { get; set; }
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace EonaCat.Connections.Client
|
||||
{
|
||||
// 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.
|
||||
|
||||
// Root myDeserializedClass = JsonConvert.DeserializeObject<List<Root>>(myJsonResponse);
|
||||
public class Contact
|
||||
{
|
||||
public string email { get; set; }
|
||||
public string phone { get; set; }
|
||||
}
|
||||
|
||||
public class Department
|
||||
{
|
||||
public string id { get; set; }
|
||||
public string name { get; set; }
|
||||
public Manager manager { get; set; }
|
||||
}
|
||||
|
||||
public class Details
|
||||
{
|
||||
public int hoursSpent { get; set; }
|
||||
public List<string> technologiesUsed { get; set; }
|
||||
public string completionDate { get; set; }
|
||||
public string expectedCompletion { get; set; }
|
||||
}
|
||||
|
||||
public class Employee
|
||||
{
|
||||
public string id { get; set; }
|
||||
public string name { get; set; }
|
||||
public string position { get; set; }
|
||||
public Department department { get; set; }
|
||||
public List<Project> projects { get; set; }
|
||||
}
|
||||
|
||||
public class Manager
|
||||
{
|
||||
public string id { get; set; }
|
||||
public string name { get; set; }
|
||||
public Contact contact { get; set; }
|
||||
}
|
||||
|
||||
public class Project
|
||||
{
|
||||
public string projectId { get; set; }
|
||||
public string projectName { get; set; }
|
||||
public string startDate { get; set; }
|
||||
public List<Task> tasks { get; set; }
|
||||
}
|
||||
|
||||
public class Root
|
||||
{
|
||||
public Employee employee { get; set; }
|
||||
}
|
||||
|
||||
public class Task
|
||||
{
|
||||
public string taskId { get; set; }
|
||||
public string title { get; set; }
|
||||
public string status { get; set; }
|
||||
public Details details { get; set; }
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -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