C# Class GSF.PhasorProtocols.MultiProtocolFrameParser.SharedUdpClientReference

Shared UDP client reference.
This class is used to create multiple IClient instances which share a single UDP client.
One shared UDP client instance will be created per local end point.
Inheritance: IClient
ファイルを表示 Open project: GridProtectionAlliance/gsf

Public Methods

Method Description
Connect ( ) : void

Connects the client to the server synchronously.

ConnectAsync ( ) : WaitHandle

Connects the client to the server asynchronously.

Derived classes are expected to override this method with protocol specific connection operations. Call the base class method to obtain an operational wait handle if protocol connection operation doesn't provide one already.

Disconnect ( ) : void

When overridden in a derived class, disconnects client from the server synchronously.

Dispose ( ) : void

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

Initialize ( ) : void

Initializes the client.

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

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

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 ClientBase.ReceiveData event handler. Calling this method outside this event will have unexpected results.

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

Sends data to the server synchronously.

SendAsync ( byte data, int offset, int length ) : WaitHandle

Sends data to the server asynchronously.

Private Methods

Method Description
GetLocalEndPoint ( ) : EndPoint

Determines the local end point this client intends to listen on via connection string properties.

GetSharedClient ( ) : void

Gets a reference to the shared client listening on this client's local end point.

OnConnectionEstablished ( ) : void
ReturnSharedClient ( ) : void

Releases a reference to this client's shared client, and disposes of the shared client if nobody is using it.

SharedClient_ConnectionAttempt ( object sender, EventArgs e ) : void
SharedClient_ConnectionEstablished ( object sender, EventArgs e ) : void
SharedClient_ConnectionException ( object sender, EventArgs e ) : void
SharedClient_ConnectionTerminated ( object sender, EventArgs e ) : void
SharedClient_ReceiveDataException ( object sender, EventArgs e ) : void
SharedClient_ReceiveDataFrom ( object sender, EventArgs e ) : void
SharedClient_SendDataException ( object sender, EventArgs e ) : void
SharedClient_UnhandledUserException ( object sender, EventArgs e ) : void
TerminateSharedClient ( ) : void

Terminates the client as quickly as possible and removes it from the collection of shared clients.

Method Details

Connect() public method

Connects the client to the server synchronously.
public Connect ( ) : void
return void

ConnectAsync() public method

Connects the client to the server asynchronously.
Derived classes are expected to override this method with protocol specific connection operations. Call the base class method to obtain an operational wait handle if protocol connection operation doesn't provide one already.
Server property in is invalid. Attempt is made to connect the client when it is not disconnected.
public ConnectAsync ( ) : WaitHandle
return System.Threading.WaitHandle

Disconnect() public method

When overridden in a derived class, disconnects client from the server synchronously.
public Disconnect ( ) : void
return void

Dispose() public method

Releases the unmanaged resources used by the client and optionally releases the managed resources.
public Dispose ( ) : void
return void

Initialize() public method

Initializes the client.
Initialize() is to be called by user-code directly only if the client is not consumed through the designer surface of the IDE.
public Initialize ( ) : void
return void

Read() public method

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 ClientBase.ReceiveData event handler. Calling this method outside this event will have unexpected results.
No received data buffer has been defined to read. is null. /// or is less than 0 -or- /// and will exceed length. ///
public Read ( byte buffer, int startIndex, int length ) : int
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 .
return int

Send() public method

Sends data to the server synchronously.
public Send ( 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 .
return void

SendAsync() public method

Sends data to the server asynchronously.
public SendAsync ( 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 .
return System.Threading.WaitHandle