C# Class CrossroadsIO.Devices.Device

Forwards messages received by a front-end socket to a back-end socket, from which they are then sent.
The base implementation of Device is not threadsafe. Do not construct a device with sockets that were created in separate threads or separate contexts.
Inheritance: IDevice
Afficher le fichier Open project: jgoz/crossroads-net Class Usage Examples

Protected Properties

Свойство Type Description
BackendSocket Socket
FrontendSocket Socket

Méthodes publiques

Méthode Description
Close ( ) : void

Stop the device and safely terminate the underlying sockets.

Dispose ( ) : void

Releases all resources used by the current instance, including the frontend and backend sockets.

Initialize ( ) : void

Initializes the frontend and backend sockets. Called automatically when starting the device. If called multiple times, will only execute once.

Join ( System.TimeSpan timeout ) : bool

Blocks the calling thread until the device terminates or the specified time elapses.

Join ( ) : void

Blocks the calling thread until the device terminates.

Start ( ) : void

Start the device in the current thread.

Stop ( ) : void

Stop the device in such a way that it can be restarted.

Méthodes protégées

Méthode Description
BackendHandler ( SocketEventArgs args ) : void

Invoked when a message has been received by the backend socket.

Device ( Socket frontendSocket, Socket backendSocket, DeviceMode mode ) : System

Initializes a new instance of the Device class.

Dispose ( bool disposing ) : void

Stops the device and releases the underlying sockets. Optionally disposes of managed resources.

FrontendHandler ( SocketEventArgs args ) : void

Invoked when a message has been received by the frontend socket.

Run ( ) : void

Start the device in the current thread. Should be used by implementations of the DeviceRunner.Start method.

Initializes the sockets prior to starting the device with Initialize.

Private Methods

Méthode Description
EnsureNotDisposed ( ) : void

Method Details

BackendHandler() protected abstract méthode

Invoked when a message has been received by the backend socket.
protected abstract BackendHandler ( SocketEventArgs args ) : void
args SocketEventArgs A object containing the poll event args.
Résultat void

Close() public méthode

Stop the device and safely terminate the underlying sockets.
public Close ( ) : void
Résultat void

Device() protected méthode

Initializes a new instance of the Device class.
protected Device ( Socket frontendSocket, Socket backendSocket, DeviceMode mode ) : System
frontendSocket Socket /// A that will pass incoming messages to . ///
backendSocket Socket /// A that will receive messages from (and optionally send replies to) . ///
mode DeviceMode The for the current device.
Résultat System

Dispose() public méthode

Releases all resources used by the current instance, including the frontend and backend sockets.
public Dispose ( ) : void
Résultat void

Dispose() protected méthode

Stops the device and releases the underlying sockets. Optionally disposes of 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

FrontendHandler() protected abstract méthode

Invoked when a message has been received by the frontend socket.
protected abstract FrontendHandler ( SocketEventArgs args ) : void
args SocketEventArgs A object containing the poll event args.
Résultat void

Initialize() public méthode

Initializes the frontend and backend sockets. Called automatically when starting the device. If called multiple times, will only execute once.
public Initialize ( ) : void
Résultat void

Join() public méthode

Blocks the calling thread until the device terminates or the specified time elapses.
public Join ( System.TimeSpan timeout ) : bool
timeout System.TimeSpan /// A set to the amount of time to wait for the device to terminate. ///
Résultat bool

Join() public méthode

Blocks the calling thread until the device terminates.
public Join ( ) : void
Résultat void

Run() protected méthode

Start the device in the current thread. Should be used by implementations of the DeviceRunner.Start method.
Initializes the sockets prior to starting the device with Initialize.
protected Run ( ) : void
Résultat void

Start() public méthode

Start the device in the current thread.
The has already been disposed.
public Start ( ) : void
Résultat void

Stop() public méthode

Stop the device in such a way that it can be restarted.
public Stop ( ) : void
Résultat void

Property Details

BackendSocket protected_oe property

The backend socket that will normally receive messages from (and possibly send replies to) FrontendSocket.
protected Socket BackendSocket
Résultat Socket

FrontendSocket protected_oe property

The frontend socket that will normally pass messages to BackendSocket.
protected Socket FrontendSocket
Résultat Socket