C# Класс 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.
Показать файл Открыть проект Примеры использования класса

Открытые методы

Метод Описание
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.

Приватные методы

Метод Описание
InternalTerminationProcedure ( ) : void

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

Описание методов

ClientConnection() публичный Метод

Constructor for ClientConnection
public ClientConnection ( TCPConnection connection ) : System
connection TCPConnection This is a TCPConnection representing the connection to the client
Результат System

Notify() публичный Метод

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
Результат void

Start() публичный Метод

Method that makes the connection start listening and writing messages to it's attached socket.
public Start ( ) : void
Результат void

Stop() публичный Метод

Method that closes the connection.
public Stop ( ) : void
Результат void