C# Class GSF.Communication.ServerBase

Inheritance: System.ComponentModel.Component, IServer, ISupportInitialize, IPersistSettings
Afficher le fichier Open project: GridProtectionAlliance/gsf Class Usage Examples

Private Properties

Свойство Type Description
BeginInit void
EndInit void

Méthodes publiques

Méthode Description
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.

Méthodes protégées

Méthode Description
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.

Private Methods

Méthode Description
BeginInit ( ) : void
EndInit ( ) : void

Method Details

Create() public static méthode

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.
Résultat IServer

DisconnectAll() public méthode

Disconnects all of the connected clients.
public DisconnectAll ( ) : void
Résultat void

DisconnectOne() public abstract méthode

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.
Résultat void

Dispose() protected méthode

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.
Résultat void

Initialize() public méthode

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
Résultat void

IsClientConnected() public méthode

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.
Résultat bool

LoadSettings() public méthode

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
Résultat void

Multicast() public méthode

Sends data to all of the connected clients synchronously.
public Multicast ( byte data ) : void
data byte The binary data that is to be sent.
Résultat void

Multicast() public méthode

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 .
Résultat void

Multicast() public méthode

Sends data to all of the connected clients synchronously.
public Multicast ( object serializableObject ) : void
serializableObject object The serializable object that is to be sent.
Résultat void

Multicast() public méthode

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.
Résultat void

MulticastAsync() public méthode

Sends data to all of the connected clients asynchronously.
public MulticastAsync ( byte data ) : WaitHandle[]
data byte The binary data that is to be sent.
Résultat WaitHandle[]

MulticastAsync() public méthode

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 .
Résultat WaitHandle[]

MulticastAsync() public méthode

Sends data to all of the connected clients asynchronously.
public MulticastAsync ( object serializableObject ) : WaitHandle[]
serializableObject object The serializable object that is to be sent.
Résultat WaitHandle[]

MulticastAsync() public méthode

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.
Résultat WaitHandle[]

OnClientConnected() protected méthode

Raises the ClientConnected event.
protected OnClientConnected ( Guid clientID ) : void
clientID Guid ID of client to send to event.
Résultat void

OnClientConnectingException() protected méthode

Raises the ClientConnectingException event.
protected OnClientConnectingException ( Exception ex ) : void
ex Exception The encountered when connecting to the client.
Résultat void

OnClientDisconnected() protected méthode

Raises the ClientDisconnected event.
protected OnClientDisconnected ( Guid clientID ) : void
clientID Guid ID of client to send to event.
Résultat void

OnReceiveClientData() protected méthode

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.
Résultat void

OnReceiveClientDataComplete() protected méthode

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.
Résultat void

OnReceiveClientDataException() protected méthode

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.
Résultat void

OnSendClientDataComplete() protected méthode

Raises the SendClientDataComplete event.
protected OnSendClientDataComplete ( Guid clientID ) : void
clientID Guid ID of client to send to event.
Résultat void

OnSendClientDataException() protected méthode

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.
Résultat void

OnSendClientDataStart() protected méthode

Raises the SendClientDataStart event.
protected OnSendClientDataStart ( Guid clientID ) : void
clientID Guid ID of client to send to event.
Résultat void

OnServerStarted() protected méthode

Raises the ServerStarted event.
protected OnServerStarted ( ) : void
Résultat void

OnServerStopped() protected méthode

Raises the ServerStopped event.
protected OnServerStopped ( ) : void
Résultat void

OnUnhandledUserException() protected méthode

Raises the UnhandledUserException event.
protected OnUnhandledUserException ( Exception ex ) : void
ex Exception Exception to send to event.
Résultat void

ReStart() protected méthode

Re-starts the server if currently running.
protected ReStart ( ) : void
Résultat void

Read() public abstract méthode

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 .
Résultat int

SaveSettings() public méthode

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
Résultat void

SendDataToAsync() protected abstract méthode

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 .
Résultat WaitHandle

SendTo() public méthode

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.
Résultat void

SendTo() public méthode

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 .
Résultat void

SendTo() public méthode

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.
Résultat void

SendTo() public méthode

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.
Résultat void

SendToAsync() public méthode

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.
Résultat WaitHandle

SendToAsync() public méthode

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 .
Résultat WaitHandle

SendToAsync() public méthode

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.
Résultat WaitHandle

SendToAsync() public méthode

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.
Résultat WaitHandle

ServerBase() protected méthode

Initializes a new instance of the server.
protected ServerBase ( ) : System
Résultat System

ServerBase() protected méthode

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.
Résultat System

Start() public abstract méthode

When overridden in a derived class, starts the server.
public abstract Start ( ) : void
Résultat void

Stop() public abstract méthode

When overridden in a derived class, stops the server.
public abstract Stop ( ) : void
Résultat void

ValidateConfigurationString() protected abstract méthode

When overridden in a derived class, validates the specified configurationString.
protected abstract ValidateConfigurationString ( string configurationString ) : void
configurationString string The configuration string to be validated.
Résultat void