C# Class Griffin.Net.ChannelTcpListener

Listens on one of the specified protocols
Inheritance: IMessagingListener
Show file Open project: jgauffin/Griffin.Framework

Public Methods

Method Description
ChannelTcpListener ( ) : System

ChannelTcpListener ( Griffin.Net.ChannelTcpListenerConfiguration configuration ) : System

Start ( IPAddress address, int port ) : void

Start this listener.

This also pre-configures 20 channels that can be used and reused during the lifetime of this listener.

Stop ( ) : void

Stop the listener.

Protected Methods

Method Description
Configure ( Griffin.Net.ChannelTcpListenerConfiguration configuration ) : void

To allow the sub classes to configure this class in their constructors.

OnClientConnected ( ITcpChannel channel ) : Griffin.Net.Protocols.ClientConnectedEventArgs

A client has connected (nothing has been sent or received yet)

OnClientDisconnected ( ITcpChannel channel, Exception exception ) : void

A client has disconnected

OnListenerError ( Exception ex ) : void

Invoke when the listener itself fails

OnMessage ( ITcpChannel source, object msg ) : void

Receive a new message from the specified client

Private Methods

Method Description
OnAcceptSocket ( IAsyncResult ar ) : void
OnChannelDisconnect ( ITcpChannel source, Exception exception ) : void

Method Details

ChannelTcpListener() public method

public ChannelTcpListener ( ) : System
return System

ChannelTcpListener() public method

public ChannelTcpListener ( Griffin.Net.ChannelTcpListenerConfiguration configuration ) : System
configuration Griffin.Net.ChannelTcpListenerConfiguration
return System

Configure() protected method

To allow the sub classes to configure this class in their constructors.
protected Configure ( Griffin.Net.ChannelTcpListenerConfiguration configuration ) : void
configuration Griffin.Net.ChannelTcpListenerConfiguration
return void

OnClientConnected() protected method

A client has connected (nothing has been sent or received yet)
protected OnClientConnected ( ITcpChannel channel ) : Griffin.Net.Protocols.ClientConnectedEventArgs
channel ITcpChannel Channel which we created for the remote socket.
return Griffin.Net.Protocols.ClientConnectedEventArgs

OnClientDisconnected() protected method

A client has disconnected
protected OnClientDisconnected ( ITcpChannel channel, Exception exception ) : void
channel ITcpChannel Channel representing the client that disconnected
exception System.Exception /// Exception which was used to detect disconnect (SocketException with status /// Success is created for graceful disconnects) ///
return void

OnListenerError() protected method

Invoke when the listener itself fails
protected OnListenerError ( Exception ex ) : void
ex System.Exception Caught exception
return void

OnMessage() protected method

Receive a new message from the specified client
protected OnMessage ( ITcpChannel source, object msg ) : void
source ITcpChannel Channel for the client
msg object Message (as decoded by the specified ).
return void

Start() public method

Start this listener.
This also pre-configures 20 channels that can be used and reused during the lifetime of this listener.
public Start ( IPAddress address, int port ) : void
address System.Net.IPAddress Address to accept connections on
port int Port to use. Set to 0 to let the OS decide which port to use.
return void

Stop() public method

Stop the listener.
public Stop ( ) : void
return void