Network Library Documentation
Loading...
Searching...
No Matches
ServerSideClient.UDP Class Reference

Class for managing UDP connection. More...

Public Member Functions

 UDP (int id)
 Initializes a new UDP object with the given client ID.
void ConnectUDP (IPEndPoint endPoint)
 Sets the remote endpoint for the UDP client.
void SendUDPData (Packet SendPacket)
 Sends a UDP packet to the client using the configured endpoint.
void UdpDataHandler (Packet data)
 Handles incoming UDP data and calls PacketAction() on the main thread.
void Disconnect ()
 Disconnects the UDP client by clearing its endpoint.

Public Attributes

IPEndPoint EndPoint

Private Attributes

int clientId

Detailed Description

Class for managing UDP connection.

Definition at line 382 of file ServerSideClient.cs.

Constructor & Destructor Documentation

◆ UDP()

ServerSideClient.UDP.UDP ( int id)

Initializes a new UDP object with the given client ID.

Definition at line 389 of file ServerSideClient.cs.

390 {
391 clientId = id;
392 }

Member Function Documentation

◆ ConnectUDP()

void ServerSideClient.UDP.ConnectUDP ( IPEndPoint endPoint)

Sets the remote endpoint for the UDP client.

Definition at line 396 of file ServerSideClient.cs.

397 {
398 EndPoint = endPoint;
399 }

◆ Disconnect()

void ServerSideClient.UDP.Disconnect ( )

Disconnects the UDP client by clearing its endpoint.

Definition at line 423 of file ServerSideClient.cs.

424 {
425 EndPoint = null;
426 }

◆ SendUDPData()

void ServerSideClient.UDP.SendUDPData ( Packet SendPacket)

Sends a UDP packet to the client using the configured endpoint.

Definition at line 403 of file ServerSideClient.cs.

404 {
405 ServerLogic.SendUDPData(EndPoint, SendPacket);
406 }

◆ UdpDataHandler()

void ServerSideClient.UDP.UdpDataHandler ( Packet data)

Handles incoming UDP data and calls PacketAction() on the main thread.

Definition at line 410 of file ServerSideClient.cs.

411 {
412 int dataLength = data.ReadInt();
413 byte[] packetBytes = data.ReadBytes(dataLength);
414 ThreadsController.StartOnMainThread(() => {
415 Packet newPacket = new Packet(packetBytes);
416 int packetId = newPacket.ReadInt();
417 ServerLogic.PacketAction(packetId, newPacket, clientId);
418 });
419 }
int ReadInt(bool changeReadPosition=true)
Read int data.
Definition Packet.cs:80
byte[] ReadBytes(int arrayLength, bool changeReadPosition=true)
read byte array data
Definition Packet.cs:188

Member Data Documentation

◆ clientId

int ServerSideClient.UDP.clientId
private

Definition at line 385 of file ServerSideClient.cs.

◆ EndPoint

IPEndPoint ServerSideClient.UDP.EndPoint

Definition at line 384 of file ServerSideClient.cs.