C# Class BF2Statistics.Gamespy.Net.GamespyTcpStream

This object is used as a Network Stream wrapper for Gamespy TCP protocol,
Inheritance: IDisposable
Show file Open project: BF2Statistics/ControlCenter Class Usage Examples

Public Properties

Property Type Description
Connection Socket

Protected Properties

Property Type Description
DisconnectEventCalled bool
RecvMessage StringBuilder
SendBytesOffset int
SendMessage List
WaitingOnAsync bool

Public Methods

Method Description
BeginReceive ( ) : void

Begins the process of receiving a message from the client. This method must manually be called to Begin receiving data

Close ( bool DisposeEventArgs = false ) : void

Closes the underlying socket

Dispose ( ) : void
GamespyTcpStream ( GamespyTcpSocket Parent, SocketAsyncEventArgs ReadArgs, SocketAsyncEventArgs WritetArgs ) : System

Creates a new instance of GamespyTcpStream

SendAsync ( byte message ) : void

Writes a message to the client stream asynchronously

SendAsync ( string message ) : void

Writes a message to the client stream asynchronously

Private Methods

Method Description
HandleSocketError ( SocketError socketError ) : void

If there was a socket error, it can be handled propery here

IOComplete ( object sender, SocketAsyncEventArgs e ) : void

Event called when data has been recived from the client

ProcessReceive ( ) : void

Once data has been recived from the client, this method is called to process the data. Once a message has been completed, the OnDataReceived event will be called

ProcessSend ( ) : void

Sends a message Asynchronously to the client connection

Method Details

BeginReceive() public method

Begins the process of receiving a message from the client. This method must manually be called to Begin receiving data
public BeginReceive ( ) : void
return void

Close() public method

Closes the underlying socket
public Close ( bool DisposeEventArgs = false ) : void
DisposeEventArgs bool /// If true, the EventArg objects will be disposed instead of being re-added to /// the IO pool. This should NEVER be set to true unless we are shutting down the server! ///
return void

Dispose() public method

public Dispose ( ) : void
return void

GamespyTcpStream() public method

Creates a new instance of GamespyTcpStream
public GamespyTcpStream ( GamespyTcpSocket Parent, SocketAsyncEventArgs ReadArgs, SocketAsyncEventArgs WritetArgs ) : System
Parent GamespyTcpSocket
ReadArgs System.Net.Sockets.SocketAsyncEventArgs
WritetArgs System.Net.Sockets.SocketAsyncEventArgs
return System

SendAsync() public method

Writes a message to the client stream asynchronously
public SendAsync ( byte message ) : void
message byte The complete message to be sent to the client
return void

SendAsync() public method

Writes a message to the client stream asynchronously
public SendAsync ( string message ) : void
message string The complete message to be sent to the client
return void

Property Details

Connection public property

Our connected socket
public Socket Connection
return Socket

DisconnectEventCalled protected property

Indicates whether the OnDisconnect event has been called
protected bool DisconnectEventCalled
return bool

RecvMessage protected property

Our message recieved from the client connection. If the message is too long, it will be sent over multiple receive operations, so we store the message parts here until we recieve the \final\ delimiter.
protected StringBuilder RecvMessage
return StringBuilder

SendBytesOffset protected property

The current send offset when sending asynchronously
protected int SendBytesOffset
return int

SendMessage protected property

Our message to send to the client. If the message is too long, it will be sent over multiple write operations, so we store the message here until its all sent
protected List SendMessage
return List

WaitingOnAsync protected property

Indicates whether we are currently sending a message asynchronously
protected bool WaitingOnAsync
return bool