UDPManager 1.0.6
dotnet add package UDPManager --version 1.0.6
NuGet\Install-Package UDPManager -Version 1.0.6
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="UDPManager" Version="1.0.6" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add UDPManager --version 1.0.6
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: UDPManager, 1.0.6"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install UDPManager as a Cake Addin #addin nuget:?package=UDPManager&version=1.0.6 // Install UDPManager as a Cake Tool #tool nuget:?package=UDPManager&version=1.0.6
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
UDPManager
The UDPManager package offers a event-driven framework on top of UDP with many reliability options, peer-to-peer communication, server and client connection features, and much more.
Sources
https://github.com/kevincastejon/cs-udp-manager
Nuget package
https://www.nuget.org/packages/UDPManager/
Documentation
https://github.com/kevincastejon/cs-udp-manager/tree/master/Documentation/html
Usages:
Peer-to-peer usage:
//Instantiate UDPManager and bind on the port of your choice
UDPManager udpm = new UDPManager(9876);
//Add listeners on the instance of UDPManager
udpm.On<UDPManagerEvent>(UDPManagerEvent.Names.BOUND, UDPManagerHandler);
udpm.On<UDPManagerEvent>(UDPManagerEvent.Names.DATA_CANCELED, UDPManagerHandler);
udpm.On<UDPManagerEvent>(UDPManagerEvent.Names.DATA_DELIVERED, UDPManagerHandler);
udpm.On<UDPManagerEvent>(UDPManagerEvent.Names.DATA_RECEIVED, UDPManagerHandler);
udpm.On<UDPManagerEvent>(UDPManagerEvent.Names.DATA_RETRIED, UDPManagerHandler);
udpm.On<UDPManagerEvent>(UDPManagerEvent.Names.DATA_SENT, UDPManagerHandler);
//Add a UDPChannel
udpm.AddChannel("mainChannel", true, true, 50, 1000);
//Send a message to the target IP and port
udpm.Send("mainChannel", new { msg = "Hello!" }, "x.x.x.x", 6789);
private void UDPManagerHandler(UDPManagerEvent e){
//Monitor UDPManagerEvents
Console.WriteLine(e.Name);
if(e.name==UDPManagerEvent.Names.DATA_RECEIVED){
//Display received messages
Console.WriteLine(e.UdpDataInfo.Data);
}
}
Client-server usage:
Client:
class UDPClientTester
{
private UDPClient client = new UDPClient();
public UDPClientTester(string serverIP, int serverPort,int localPort=0)
{
client.AddEventListener<UDPManagerEvent>(UDPManagerEvent.Names.BOUND, UDPManagerHandler);
client.AddEventListener<UDPClientEvent>(UDPClientEvent.Names.CONNECTED_TO_SERVER, ClientHandler);
client.AddEventListener<UDPClientEvent>(UDPClientEvent.Names.CONNECTION_FAILED, ClientHandler);
client.AddEventListener<UDPClientEvent>(UDPClientEvent.Names.SERVER_PONG, ClientHandler);
client.AddEventListener<UDPClientEvent>(UDPClientEvent.Names.SERVER_SENT_DATA, ClientHandler);
client.AddEventListener<UDPClientEvent>(UDPClientEvent.Names.SERVER_TIMED_OUT, ClientHandler);
client.AddChannel("mainChannel", false, true, 50, 1000);
client.Connect(serverIP, serverPort, localPort);
}
private void ClientHandler(UDPClientEvent e)
{
//Console.WriteLine("clientside event: "+e.Name);
if (e.Name == UDPClientEvent.Names.CONNECTED_TO_SERVER.ToString())
{
client.SendToServer("mainChannel", new { message = "Thanks for accepting my connection !" });
}
else if (e.Name == UDPClientEvent.Names.SERVER_SENT_DATA.ToString())
{
Console.WriteLine("Server sent : " + e.UDPdataInfo.Data["message"]);
}
}
private void UDPManagerHandler(UDPManagerEvent e)
{
Console.WriteLine(e.Name);
}
}
Server:
class UDPServerTester
{
UDPServer server = new UDPServer();
public UDPServerTester(int localPort)
{
server.AddEventListener<UDPManagerEvent>(UDPManagerEvent.Names.BOUND, UDPManagerHandler);
server.AddEventListener<UDPServerEvent>(UDPServerEvent.Names.CLIENT_CONNECTED, ServerHandler);
server.AddEventListener<UDPServerEvent>(UDPServerEvent.Names.CLIENT_PONG, ServerHandler);
server.AddEventListener<UDPServerEvent>(UDPServerEvent.Names.CLIENT_RECONNECTED, ServerHandler);
server.AddEventListener<UDPServerEvent>(UDPServerEvent.Names.CLIENT_SENT_DATA, ServerHandler);
server.AddEventListener<UDPServerEvent>(UDPServerEvent.Names.CLIENT_TIMED_OUT, ServerHandler);
server.AddChannel("mainChannel",false,true,50,1000);
server.Start(localPort);
}
private void ServerHandler(UDPServerEvent e)
{
if(e.Name == UDPServerEvent.Names.CLIENT_CONNECTED.ToString())
{
Console.WriteLine("A client is connected! ID:" + e.UDPpeer.ID.ToString());
}
else if (e.Name == UDPServerEvent.Names.CLIENT_SENT_DATA.ToString())
{
Console.WriteLine("Client sent : " + e.UDPdataInfo.Data["message"]);
server.SendToClient("mainChannel",new { message="You're welcome!"},e.UDPpeer);
}
}
private void UDPManagerHandler(UDPManagerEvent e)
{
Console.WriteLine(e.Name);
}
}
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET Framework | net461 is compatible. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
- EventManager (>= 1.0.6)
- Newtonsoft.Json (>= 12.0.3)
- TimerEvent (>= 1.0.6)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.