C# Class ServerNetworkConnections.ClientConnection

This class represents a connection to a remote host. It is possible to notify this host with messages that extends upon the "AbstractMessage" class. HOW TO USE: * Initialize the class with needed parameters (see constructor) * Call "Start()" method to start listening for incoming messages and start to write messages * Whenever a message is received from the server, the OnMessageReceived callback is called. * Whenever a message is received but in a corrupted format, the OnMessageFailed is called. * If the connection to the server fails, the OnConnectionFailed is called. The underlying connection will automatically be closed, so you do not need to call the stop method if this delegate is fired. * Writing to the server is non-blocking. All it does is to place the message into a buffer that is then handled by another thread.
Datei anzeigen Open project: bakacaptain/istalkapp Class Usage Examples

Public Methods

Method Description
ClientConnection ( TCPConnection connection ) : System

Constructor for ClientConnection

Notify ( AbstractMessage msg ) : void

Method that places a message in a buffer to be sent to the server. This is a non-blocking call.

Start ( ) : void

Method that makes the connection start listening and writing messages to it's attached socket.

Stop ( ) : void

Method that closes the connection.

Private Methods

Method Description
InternalTerminationProcedure ( ) : void

Internal methods to terminate the ClientConnection when an unexpected failure happens.

Method Details

ClientConnection() public method

Constructor for ClientConnection
public ClientConnection ( TCPConnection connection ) : System
connection TCPConnection This is a TCPConnection representing the connection to the client
return System

Notify() public method

Method that places a message in a buffer to be sent to the server. This is a non-blocking call.
public Notify ( AbstractMessage msg ) : void
msg AbstractMessage
return void

Start() public method

Method that makes the connection start listening and writing messages to it's attached socket.
public Start ( ) : void
return void

Stop() public method

Method that closes the connection.
public Stop ( ) : void
return void