ProtonNet Server 1.0
An Open Solution for all your socket or web api needs.
Loading...
Searching...
No Matches
XmobiTea.ProtonNetServer.UdpSession Class Reference

Represents a UDP session that handles communication with a remote endpoint. More...

Inheritance diagram for XmobiTea.ProtonNetServer.UdpSession:
XmobiTea.ProtonNetServer.IUdpSession XmobiTea.ProtonNetServer.ISession XmobiTea.ProtonNet.Server.Socket.Sessions.SocketUdpSession

Public Member Functions

 UdpSession (UdpServer server)
 Initializes a new instance of the UdpSession class with the specified server.
 
INetworkStatistics GetNetworkStatistics ()
 Gets the network statistics for the session.
 
virtual bool Disconnect ()
 Disconnects the session.
 
int Send (byte[] buffer)
 Sends data synchronously to the remote endpoint.
 
int Send (byte[] buffer, int position, int length)
 Sends data synchronously to the remote endpoint with a specified position and length.
 
bool SendAsync (byte[] buffer)
 Sends data asynchronously to the remote endpoint.
 
bool SendAsync (byte[] buffer, int position, int length)
 Sends data asynchronously to the remote endpoint with a specified position and length.
 
void Dispose ()
 Disposes the session and its resources.
 
- Public Member Functions inherited from XmobiTea.ProtonNetServer.ISession

Protected Member Functions

virtual void OnConnecting ()
 Called when the session is connecting. Override this method to add custom logic during connection.
 
virtual void OnConnected ()
 Called after the session has connected successfully. Override this method to add custom logic after connection.
 
virtual void OnDisconnecting ()
 Called when the session is disconnecting. Override this method to add custom logic during disconnection.
 
virtual void OnDisconnected ()
 Called after the session has disconnected successfully. Override this method to add custom logic after disconnection.
 
virtual void OnReceived (byte[] buffer, int position, int length)
 Called when data is received from the remote endpoint. Override this method to process received data.
 
virtual void OnSent (int sent)
 Called after data has been sent to the remote endpoint. Override this method to add custom logic after sending data.
 
virtual void OnError (SocketError error)
 Called when a socket error occurs. Override this method to handle errors in a custom way.
 
virtual void Dispose (bool disposingManagedResources)
 Disposes the session, optionally releasing managed resources.
 

Properties

string Id [get]
 Gets the unique identifier for the session.
 
UdpServer Server [get]
 Gets the server associated with this session.
 
System.Net.EndPoint RemoteEndPoint [get]
 Gets the remote endpoint for this session.
 
bool IsConnected [get]
 Gets a value indicating whether the session is connected.
 
bool IsDisposed [get]
 Gets a value indicating whether the session is disposed.
 

Detailed Description

Represents a UDP session that handles communication with a remote endpoint.

Constructor & Destructor Documentation

◆ UdpSession()

XmobiTea.ProtonNetServer.UdpSession.UdpSession ( UdpServer server)

Initializes a new instance of the UdpSession class with the specified server.

Parameters
serverThe server associated with this session.

Member Function Documentation

◆ Disconnect()

virtual bool XmobiTea.ProtonNetServer.UdpSession.Disconnect ( )
virtual

Disconnects the session.

Returns
True if the session was disconnected successfully; otherwise, false.

Implements XmobiTea.ProtonNetServer.ISession.

◆ Dispose()

virtual void XmobiTea.ProtonNetServer.UdpSession.Dispose ( bool disposingManagedResources)
protectedvirtual

Disposes the session, optionally releasing managed resources.

Parameters
disposingManagedResourcesTrue to release managed resources; otherwise, false.

Reimplemented in XmobiTea.ProtonNet.Server.Socket.Sessions.SocketUdpSession.

◆ GetNetworkStatistics()

INetworkStatistics XmobiTea.ProtonNetServer.UdpSession.GetNetworkStatistics ( )

Gets the network statistics for the session.

Returns
An instance of INetworkStatistics representing the network statistics.

Implements XmobiTea.ProtonNetServer.ISession.

◆ OnConnected()

virtual void XmobiTea.ProtonNetServer.UdpSession.OnConnected ( )
protectedvirtual

Called after the session has connected successfully. Override this method to add custom logic after connection.

Reimplemented in XmobiTea.ProtonNet.Server.Socket.Sessions.SocketUdpSession.

◆ OnDisconnected()

virtual void XmobiTea.ProtonNetServer.UdpSession.OnDisconnected ( )
protectedvirtual

Called after the session has disconnected successfully. Override this method to add custom logic after disconnection.

Reimplemented in XmobiTea.ProtonNet.Server.Socket.Sessions.SocketUdpSession.

◆ OnError()

virtual void XmobiTea.ProtonNetServer.UdpSession.OnError ( SocketError error)
protectedvirtual

Called when a socket error occurs. Override this method to handle errors in a custom way.

Parameters
errorThe SocketError that occurred.

◆ OnReceived()

virtual void XmobiTea.ProtonNetServer.UdpSession.OnReceived ( byte[] buffer,
int position,
int length )
protectedvirtual

Called when data is received from the remote endpoint. Override this method to process received data.

Parameters
bufferThe received data buffer.
positionThe starting position in the buffer.
lengthThe length of the received data.

Reimplemented in XmobiTea.ProtonNet.Server.Socket.Sessions.SocketUdpSession.

◆ OnSent()

virtual void XmobiTea.ProtonNetServer.UdpSession.OnSent ( int sent)
protectedvirtual

Called after data has been sent to the remote endpoint. Override this method to add custom logic after sending data.

Parameters
sentThe number of bytes sent.

◆ Send() [1/2]

int XmobiTea.ProtonNetServer.UdpSession.Send ( byte[] buffer)

Sends data synchronously to the remote endpoint.

Parameters
bufferThe data buffer to send.
Returns
The number of bytes sent.

Implements XmobiTea.ProtonNetServer.ISession.

◆ Send() [2/2]

int XmobiTea.ProtonNetServer.UdpSession.Send ( byte[] buffer,
int position,
int length )

Sends data synchronously to the remote endpoint with a specified position and length.

Parameters
bufferThe data buffer to send.
positionThe starting position in the buffer.
lengthThe length of the data to send.
Returns
The number of bytes sent.

Implements XmobiTea.ProtonNetServer.ISession.

◆ SendAsync() [1/2]

bool XmobiTea.ProtonNetServer.UdpSession.SendAsync ( byte[] buffer)

Sends data asynchronously to the remote endpoint.

Parameters
bufferThe data buffer to send.
Returns
True if the data was sent successfully; otherwise, false.

Implements XmobiTea.ProtonNetServer.ISession.

◆ SendAsync() [2/2]

bool XmobiTea.ProtonNetServer.UdpSession.SendAsync ( byte[] buffer,
int position,
int length )

Sends data asynchronously to the remote endpoint with a specified position and length.

Parameters
bufferThe data buffer to send.
positionThe starting position in the buffer.
lengthThe length of the data to send.
Returns
True if the data was sent successfully; otherwise, false.

Implements XmobiTea.ProtonNetServer.ISession.


The documentation for this class was generated from the following file: