C# Класс GSF.Communication.ServerBase

Наследование: System.ComponentModel.Component, IServer, ISupportInitialize, IPersistSettings
Показать файл Открыть проект Примеры использования класса

Private Properties

Свойство Тип Описание
BeginInit void
EndInit void

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

Метод Описание
Create ( string configurationString ) : IServer

Create a communications server

Note that typical configuration string should be prefixed with a "protocol=tcp" or a "protocol=udp"

DisconnectAll ( ) : void

Disconnects all of the connected clients.

DisconnectOne ( System.Guid clientID ) : void

When overridden in a derived class, disconnects a connected client.

Initialize ( ) : void

Initializes the server.

Initialize() is to be called by user-code directly only if the server is not consumed through the designer surface of the IDE.

IsClientConnected ( System.Guid clientID ) : bool

Determines whether the given client is currently connected to the server.

LoadSettings ( ) : void

Loads saved server settings from the config file if the PersistSettings property is set to true.

Multicast ( byte data ) : void

Sends data to all of the connected clients synchronously.

Multicast ( byte data, int offset, int length ) : void

Sends data to all of the connected clients synchronously.

Multicast ( object serializableObject ) : void

Sends data to all of the connected clients synchronously.

Multicast ( string data ) : void

Sends data to all of the connected clients synchronously.

MulticastAsync ( byte data ) : WaitHandle[]

Sends data to all of the connected clients asynchronously.

MulticastAsync ( byte data, int offset, int length ) : WaitHandle[]

Sends data to all of the connected clients asynchronously.

MulticastAsync ( object serializableObject ) : WaitHandle[]

Sends data to all of the connected clients asynchronously.

MulticastAsync ( string data ) : WaitHandle[]

Sends data to all of the connected clients asynchronously.

Read ( Guid clientID, byte buffer, int startIndex, int length ) : int

When overridden in a derived class, reads a number of bytes from the current received data buffer and writes those bytes into a byte array at the specified offset.

This function should only be called from within the ReceiveClientData event handler. Calling this method outside this event will have unexpected results.

SaveSettings ( ) : void

Saves server settings to the config file if the PersistSettings property is set to true.

SendTo ( Guid clientID, byte data ) : void

Sends data to the specified client synchronously.

SendTo ( Guid clientID, byte data, int offset, int length ) : void

Sends data to the specified client synchronously.

SendTo ( Guid clientID, object serializableObject ) : void

Sends data to the specified client synchronously.

SendTo ( Guid clientID, string data ) : void

Sends data to the specified client synchronously.

SendToAsync ( Guid clientID, byte data ) : WaitHandle

Sends data to the specified client asynchronously.

SendToAsync ( Guid clientID, byte data, int offset, int length ) : WaitHandle

Sends data to the specified client asynchronously.

SendToAsync ( Guid clientID, object serializableObject ) : WaitHandle

Sends data to the specified client asynchronously.

SendToAsync ( Guid clientID, string data ) : WaitHandle

Sends data to the specified client asynchronously.

Start ( ) : void

When overridden in a derived class, starts the server.

Stop ( ) : void

When overridden in a derived class, stops the server.

Защищенные методы

Метод Описание
Dispose ( bool disposing ) : void

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

OnClientConnected ( Guid clientID ) : void

Raises the ClientConnected event.

OnClientConnectingException ( Exception ex ) : void

Raises the ClientConnectingException event.

OnClientDisconnected ( Guid clientID ) : void

Raises the ClientDisconnected event.

OnReceiveClientData ( Guid clientID, int size ) : void

Raises the ReceiveClientData event.

This event is automatically raised by call to OnReceiveClientDataComplete so that inheritors never need to worry about raising this event. This method is only included here in case any custom server implementations need to explicitly raise this event.

OnReceiveClientDataComplete ( Guid clientID, byte data, int size ) : void

Raises the ReceiveClientDataComplete event.

OnReceiveClientDataException ( Guid clientID, Exception ex ) : void

Raises the ReceiveClientDataException event.

OnSendClientDataComplete ( Guid clientID ) : void

Raises the SendClientDataComplete event.

OnSendClientDataException ( Guid clientID, Exception ex ) : void

Raises the SendClientDataException event.

OnSendClientDataStart ( Guid clientID ) : void

Raises the SendClientDataStart event.

OnServerStarted ( ) : void

Raises the ServerStarted event.

OnServerStopped ( ) : void

Raises the ServerStopped event.

OnUnhandledUserException ( Exception ex ) : void

Raises the UnhandledUserException event.

ReStart ( ) : void

Re-starts the server if currently running.

SendDataToAsync ( Guid clientID, byte data, int offset, int length ) : WaitHandle

When overridden in a derived class, sends data to the specified client asynchronously.

ServerBase ( ) : System

Initializes a new instance of the server.

ServerBase ( TransportProtocol transportProtocol, string configurationString ) : System

Initializes a new instance of the server.

ValidateConfigurationString ( string configurationString ) : void

When overridden in a derived class, validates the specified configurationString.

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

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

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

Create() публичный статический Метод

Create a communications server
Note that typical configuration string should be prefixed with a "protocol=tcp" or a "protocol=udp"
public static Create ( string configurationString ) : IServer
configurationString string The configuration string for the server.
Результат IServer

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

Disconnects all of the connected clients.
public DisconnectAll ( ) : void
Результат void

DisconnectOne() публичный абстрактный Метод

When overridden in a derived class, disconnects a connected client.
public abstract DisconnectOne ( System.Guid clientID ) : void
clientID System.Guid ID of the client to be disconnected.
Результат void

Dispose() защищенный Метод

Releases the unmanaged resources used by the server and optionally releases the managed resources.
protected Dispose ( bool disposing ) : void
disposing bool true to release both managed and unmanaged resources; false to release only unmanaged resources.
Результат void

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

Initializes the server.
Initialize() is to be called by user-code directly only if the server is not consumed through the designer surface of the IDE.
public Initialize ( ) : void
Результат void

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

Determines whether the given client is currently connected to the server.
public IsClientConnected ( System.Guid clientID ) : bool
clientID System.Guid The ID of the client.
Результат bool

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

Loads saved server settings from the config file if the PersistSettings property is set to true.
has a value of null or empty string.
public LoadSettings ( ) : void
Результат void

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

Sends data to all of the connected clients synchronously.
public Multicast ( byte data ) : void
data byte The binary data that is to be sent.
Результат void

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

Sends data to all of the connected clients synchronously.
public Multicast ( byte data, int offset, int length ) : void
data byte The buffer that contains the binary data to be sent.
offset int The zero-based position in the at which to begin sending data.
length int The number of bytes to be sent from starting at the .
Результат void

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

Sends data to all of the connected clients synchronously.
public Multicast ( object serializableObject ) : void
serializableObject object The serializable object that is to be sent.
Результат void

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

Sends data to all of the connected clients synchronously.
public Multicast ( string data ) : void
data string The plain-text data that is to be sent.
Результат void

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

Sends data to all of the connected clients asynchronously.
public MulticastAsync ( byte data ) : WaitHandle[]
data byte The binary data that is to be sent.
Результат WaitHandle[]

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

Sends data to all of the connected clients asynchronously.
public MulticastAsync ( byte data, int offset, int length ) : WaitHandle[]
data byte The buffer that contains the binary data to be sent.
offset int The zero-based position in the at which to begin sending data.
length int The number of bytes to be sent from starting at the .
Результат WaitHandle[]

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

Sends data to all of the connected clients asynchronously.
public MulticastAsync ( object serializableObject ) : WaitHandle[]
serializableObject object The serializable object that is to be sent.
Результат WaitHandle[]

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

Sends data to all of the connected clients asynchronously.
public MulticastAsync ( string data ) : WaitHandle[]
data string The plain-text data that is to be sent.
Результат WaitHandle[]

OnClientConnected() защищенный Метод

Raises the ClientConnected event.
protected OnClientConnected ( Guid clientID ) : void
clientID Guid ID of client to send to event.
Результат void

OnClientConnectingException() защищенный Метод

Raises the ClientConnectingException event.
protected OnClientConnectingException ( Exception ex ) : void
ex Exception The encountered when connecting to the client.
Результат void

OnClientDisconnected() защищенный Метод

Raises the ClientDisconnected event.
protected OnClientDisconnected ( Guid clientID ) : void
clientID Guid ID of client to send to event.
Результат void

OnReceiveClientData() защищенный Метод

Raises the ReceiveClientData event.
This event is automatically raised by call to OnReceiveClientDataComplete so that inheritors never need to worry about raising this event. This method is only included here in case any custom server implementations need to explicitly raise this event.
protected OnReceiveClientData ( Guid clientID, int size ) : void
clientID Guid ID of the client from which data is received.
size int Number of bytes received from the client.
Результат void

OnReceiveClientDataComplete() защищенный Метод

Raises the ReceiveClientDataComplete event.
protected OnReceiveClientDataComplete ( Guid clientID, byte data, int size ) : void
clientID Guid ID of the client from which data is received.
data byte Data received from the client.
size int Number of bytes received from the client.
Результат void

OnReceiveClientDataException() защищенный Метод

Raises the ReceiveClientDataException event.
protected OnReceiveClientDataException ( Guid clientID, Exception ex ) : void
clientID Guid ID of client to send to event.
ex Exception Exception to send to event.
Результат void

OnSendClientDataComplete() защищенный Метод

Raises the SendClientDataComplete event.
protected OnSendClientDataComplete ( Guid clientID ) : void
clientID Guid ID of client to send to event.
Результат void

OnSendClientDataException() защищенный Метод

Raises the SendClientDataException event.
protected OnSendClientDataException ( Guid clientID, Exception ex ) : void
clientID Guid ID of client to send to event.
ex Exception Exception to send to event.
Результат void

OnSendClientDataStart() защищенный Метод

Raises the SendClientDataStart event.
protected OnSendClientDataStart ( Guid clientID ) : void
clientID Guid ID of client to send to event.
Результат void

OnServerStarted() защищенный Метод

Raises the ServerStarted event.
protected OnServerStarted ( ) : void
Результат void

OnServerStopped() защищенный Метод

Raises the ServerStopped event.
protected OnServerStopped ( ) : void
Результат void

OnUnhandledUserException() защищенный Метод

Raises the UnhandledUserException event.
protected OnUnhandledUserException ( Exception ex ) : void
ex Exception Exception to send to event.
Результат void

ReStart() защищенный Метод

Re-starts the server if currently running.
protected ReStart ( ) : void
Результат void

Read() публичный абстрактный Метод

When overridden in a derived class, reads a number of bytes from the current received data buffer and writes those bytes into a byte array at the specified offset.
This function should only be called from within the ReceiveClientData event handler. Calling this method outside this event will have unexpected results.
public abstract Read ( Guid clientID, byte buffer, int startIndex, int length ) : int
clientID Guid ID of the client from which data buffer should be read.
buffer byte Destination buffer used to hold copied bytes.
startIndex int 0-based starting index into destination to begin writing data.
length int The number of bytes to read from current received data buffer and write into .
Результат int

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

Saves server settings to the config file if the PersistSettings property is set to true.
has a value of null or empty string.
public SaveSettings ( ) : void
Результат void

SendDataToAsync() защищенный абстрактный Метод

When overridden in a derived class, sends data to the specified client asynchronously.
protected abstract SendDataToAsync ( Guid clientID, byte data, int offset, int length ) : WaitHandle
clientID Guid ID of the client to which the data is to be sent.
data byte The buffer that contains the binary data to be sent.
offset int The zero-based position in the at which to begin sending data.
length int The number of bytes to be sent from starting at the .
Результат WaitHandle

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

Sends data to the specified client synchronously.
public SendTo ( Guid clientID, byte data ) : void
clientID Guid ID of the client to which the data is to be sent.
data byte The binary data that is to be sent.
Результат void

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

Sends data to the specified client synchronously.
public SendTo ( Guid clientID, byte data, int offset, int length ) : void
clientID Guid ID of the client to which the data is to be sent.
data byte The buffer that contains the binary data to be sent.
offset int The zero-based position in the at which to begin sending data.
length int The number of bytes to be sent from starting at the .
Результат void

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

Sends data to the specified client synchronously.
public SendTo ( Guid clientID, object serializableObject ) : void
clientID Guid ID of the client to which the data is to be sent.
serializableObject object The serializable object that is to be sent.
Результат void

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

Sends data to the specified client synchronously.
public SendTo ( Guid clientID, string data ) : void
clientID Guid ID of the client to which the data is to be sent.
data string The plain-text data that is to be sent.
Результат void

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

Sends data to the specified client asynchronously.
public SendToAsync ( Guid clientID, byte data ) : WaitHandle
clientID Guid ID of the client to which the data is to be sent.
data byte The binary data that is to be sent.
Результат WaitHandle

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

Sends data to the specified client asynchronously.
public SendToAsync ( Guid clientID, byte data, int offset, int length ) : WaitHandle
clientID Guid ID of the client to which the data is to be sent.
data byte The buffer that contains the binary data to be sent.
offset int The zero-based position in the at which to begin sending data.
length int The number of bytes to be sent from starting at the .
Результат WaitHandle

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

Sends data to the specified client asynchronously.
public SendToAsync ( Guid clientID, object serializableObject ) : WaitHandle
clientID Guid ID of the client to which the data is to be sent.
serializableObject object The serializable object that is to be sent.
Результат WaitHandle

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

Sends data to the specified client asynchronously.
public SendToAsync ( Guid clientID, string data ) : WaitHandle
clientID Guid ID of the client to which the data is to be sent.
data string The plain-text data that is to be sent.
Результат WaitHandle

ServerBase() защищенный Метод

Initializes a new instance of the server.
protected ServerBase ( ) : System
Результат System

ServerBase() защищенный Метод

Initializes a new instance of the server.
protected ServerBase ( TransportProtocol transportProtocol, string configurationString ) : System
transportProtocol TransportProtocol One of the values.
configurationString string The data used by the server for initialization.
Результат System

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

When overridden in a derived class, starts the server.
public abstract Start ( ) : void
Результат void

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

When overridden in a derived class, stops the server.
public abstract Stop ( ) : void
Результат void

ValidateConfigurationString() защищенный абстрактный Метод

When overridden in a derived class, validates the specified configurationString.
protected abstract ValidateConfigurationString ( string configurationString ) : void
configurationString string The configuration string to be validated.
Результат void