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

Provides the implementation for a TCP session, handling connection, data transmission, and disconnection. More...

Inheritance diagram for XmobiTea.ProtonNetServer.TcpSession:
XmobiTea.ProtonNetServer.ITcpSession XmobiTea.ProtonNetServer.ISession XmobiTea.ProtonNet.Server.Socket.Sessions.SocketTcpSession XmobiTea.ProtonNetServer.HttpSession XmobiTea.ProtonNet.Server.WebApi.Sessions.WebApiHttpSession XmobiTea.ProtonNetServer.WsSession XmobiTea.ProtonNet.Server.Socket.Sessions.SocketWsSession

Public Member Functions

 TcpSession (TcpServer server)
 Initializes a new instance of the TcpSession class.
 
INetworkStatistics GetNetworkStatistics ()
 Gets the network statistics for this session.
 
virtual bool Disconnect ()
 Disconnects the session.
 
virtual int Send (byte[] buffer)
 Sends data synchronously.
 
virtual int Send (byte[] buffer, int position, int length)
 Sends data synchronously with the specified position and length.
 
virtual bool SendAsync (byte[] buffer)
 Sends data asynchronously.
 
virtual bool SendAsync (byte[] buffer, int position, int length)
 Sends data asynchronously with the specified position and length.
 
void Dispose ()
 Releases all resources used by the current instance of the TcpSession class.
 
- Public Member Functions inherited from XmobiTea.ProtonNetServer.ISession

Protected Member Functions

virtual void OnConnecting ()
 Invoked when the session is in the process of connecting.
 
virtual void OnConnected ()
 Invoked when the session has successfully connected.
 
virtual void OnDisconnecting ()
 Invoked when the session is in the process of disconnecting.
 
virtual void OnDisconnected ()
 Invoked when the session has successfully disconnected.
 
virtual void OnReceived (byte[] buffer, int position, int length)
 Invoked when data is received from the remote endpoint.
 
virtual void OnSent (int sent, int pending)
 Invoked when data is successfully sent to the remote endpoint.
 
virtual void OnEmpty ()
 Invoked when the send buffer is empty.
 
virtual void OnError (SocketError error)
 Invoked when an error occurs during the session operation.
 
virtual void Dispose (bool disposingManagedResources)
 Releases the unmanaged resources used by the TcpSession and optionally releases the managed resources.
 

Properties

string Id [get]
 Gets the unique identifier for this session.
 
TcpServer Server [get]
 Gets the server that owns this session.
 
Socket Socket [get]
 Gets the socket associated with this session.
 
bool IsConnected [get]
 Gets a value indicating whether the session is currently connected.
 
bool IsDisposed [get]
 Gets a value indicating whether the session has been disposed.
 
bool IsSocketDisposed [get]
 Gets a value indicating whether the socket has been disposed.
 
TcpServerOptions Options [get]
 Gets the options for the TCP server.
 

Detailed Description

Provides the implementation for a TCP session, handling connection, data transmission, and disconnection.

Constructor & Destructor Documentation

◆ TcpSession()

XmobiTea.ProtonNetServer.TcpSession.TcpSession ( TcpServer server)

Initializes a new instance of the TcpSession class.

Parameters
serverThe server that owns this session.

Member Function Documentation

◆ Disconnect()

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

Disconnects the session.

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

Implements XmobiTea.ProtonNetServer.ISession.

◆ Dispose()

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

Releases the unmanaged resources used by the TcpSession and optionally releases the managed resources.

Parameters
disposingManagedResourcesTrue to release both managed and unmanaged resources; false to release only unmanaged resources.

Reimplemented in XmobiTea.ProtonNet.Server.Socket.Sessions.SocketTcpSession, and XmobiTea.ProtonNet.Server.Socket.Sessions.SocketWsSession.

◆ GetNetworkStatistics()

INetworkStatistics XmobiTea.ProtonNetServer.TcpSession.GetNetworkStatistics ( )

Gets the network statistics for this session.

Returns
The network statistics.

Implements XmobiTea.ProtonNetServer.ISession.

◆ OnConnected()

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

Invoked when the session has successfully connected.

Reimplemented in XmobiTea.ProtonNet.Server.Socket.Sessions.SocketTcpSession, and XmobiTea.ProtonNet.Server.WebApi.Sessions.WebApiHttpSession.

◆ OnDisconnected()

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

◆ OnDisconnecting()

virtual void XmobiTea.ProtonNetServer.TcpSession.OnDisconnecting ( )
protectedvirtual

Invoked when the session is in the process of disconnecting.

Reimplemented in XmobiTea.ProtonNetServer.WsSession.

◆ OnError()

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

Invoked when an error occurs during the session operation.

Parameters
errorThe socket error that occurred.

◆ OnReceived()

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

Invoked when data is received from the remote endpoint.

Parameters
bufferThe buffer containing the received data.
positionThe position in the buffer where the received data starts.
lengthThe length of the received data.

Reimplemented in XmobiTea.ProtonNet.Server.Socket.Sessions.SocketTcpSession, XmobiTea.ProtonNetServer.HttpSession, and XmobiTea.ProtonNetServer.WsSession.

◆ OnSent()

virtual void XmobiTea.ProtonNetServer.TcpSession.OnSent ( int sent,
int pending )
protectedvirtual

Invoked when data is successfully sent to the remote endpoint.

Parameters
sentThe number of bytes sent.
pendingThe number of bytes pending in the send buffer.

◆ Send() [1/2]

virtual int XmobiTea.ProtonNetServer.TcpSession.Send ( byte[] buffer)
virtual

Sends data synchronously.

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

Implements XmobiTea.ProtonNetServer.ISession.

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

◆ Send() [2/2]

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

Sends data synchronously with the specified position and length.

Parameters
bufferThe buffer containing the data 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]

virtual bool XmobiTea.ProtonNetServer.TcpSession.SendAsync ( byte[] buffer)
virtual

Sends data asynchronously.

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

Implements XmobiTea.ProtonNetServer.ISession.

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

◆ SendAsync() [2/2]

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

Sends data asynchronously with the specified position and length.

Parameters
bufferThe buffer containing the data 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: