C# Class ServerNetworkConnections.TCPConnection

Class that encapsulates a socket into a more convenient unit from which you can write AbstractMessage to and read AbstractMessages from
Show file Open project: bakacaptain/istalkapp Class Usage Examples

Public Methods

Method Description
Close ( ) : void

Closes the TCPConnection.

Read ( ) : AbstractMessage

Reads an AbstractMessage from the TCPConnection. Will throw an XmlException if an invalid Xml message was received.

TCPConnection ( String hostname, UInt16 port, AbstractMessageParser parser ) : System

Initializes the TCPConnection to the given hostname / port.

TCPConnection ( TcpClient client, AbstractMessageParser parser ) : System

Initializes the TCPConnection with the given TcpClient.

Write ( AbstractMessage msg ) : void

Writes the given AbstractMessage into the TCPConnection.

Method Details

Close() public method

Closes the TCPConnection.
public Close ( ) : void
return void

Read() public method

Reads an AbstractMessage from the TCPConnection. Will throw an XmlException if an invalid Xml message was received.
public Read ( ) : AbstractMessage
return AbstractMessage

TCPConnection() public method

Initializes the TCPConnection to the given hostname / port.
public TCPConnection ( String hostname, UInt16 port, AbstractMessageParser parser ) : System
hostname String A String with the hostname of the server
port System.UInt16 A UInt16 with the port of the server.
parser AbstractMessageParser
return System

TCPConnection() public method

Initializes the TCPConnection with the given TcpClient.
public TCPConnection ( TcpClient client, AbstractMessageParser parser ) : System
client System.Net.Sockets.TcpClient The TcpClient to the server.
parser AbstractMessageParser
return System

Write() public method

Writes the given AbstractMessage into the TCPConnection.
public Write ( AbstractMessage msg ) : void
msg AbstractMessage
return void