C# Class Cakewalk.NetEntity

Networking core of the server
Inheritance: IDisposable
Datei anzeigen Open project: Cakez0r/Cakewalk

Public Properties

Property Type Description
BIN int
BOUT int
IN int
OUT int

Protected Properties

Property Type Description
m_receiveArgs System.Net.Sockets.SocketAsyncEventArgs
m_sendArgs System.Net.Sockets.SocketAsyncEventArgs

Public Methods

Method Description
Authorise ( ) : void

Send an authorisation request.

DeferredSendPacket ( IPacketBase packet ) : void

Queues a packet to be send on the next update. Will coalesce these packets together.

Dispose ( ) : void

Clean up this entity

NetEntity ( Socket socket, int worldID, SocketAsyncEventArgs sendEventArgs, SocketAsyncEventArgs receiveEventArgs ) : System

Create a new entity from a socket and immediately assign it a world id. Requires async socket context objects with buffers pre-assigned

SendClockSync ( ) : void

Send a clock sync request, if there is not already one pending.

SendPacket ( IPacketBase packet ) : void

Enqueue a packet for sending over the wire

Update ( System.TimeSpan dt ) : void

Updates this entity, flushes and handles any pending packets in the incoming queue.

Protected Methods

Method Description
HandlePacket ( IPacketBase packet ) : void

Packet handler logic

Private Methods

Method Description
DeserializePacket ( IntPtr buffer ) : int

Deserializes a packet from the given buffer. Returns the amount of bytes consumed.

QueueReceive ( ) : void

Begins data receive task on the thread pool

QueueSend ( ) : void

Begins data send task on the thread pool

Receive ( ) : void

Starts an async receive from the socket

ReceiveCompleted ( object sender, SocketAsyncEventArgs e ) : void

Handle a received packet

Send ( ) : void

Poll the outgoing queue and send any packets

SendCompleted ( object sender, SocketAsyncEventArgs e ) : void

Event handler for async send completion

SerializePacket ( IPacketBase packet ) : void

Serialize the given packet into the send buffer.

SyncClock ( int remoteTime ) : void

Synchronises the network clock using any round trip time data available.

Method Details

Authorise() public method

Send an authorisation request.
public Authorise ( ) : void
return void

DeferredSendPacket() public method

Queues a packet to be send on the next update. Will coalesce these packets together.
public DeferredSendPacket ( IPacketBase packet ) : void
packet IPacketBase
return void

Dispose() public method

Clean up this entity
public Dispose ( ) : void
return void

HandlePacket() protected method

Packet handler logic
protected HandlePacket ( IPacketBase packet ) : void
packet IPacketBase
return void

NetEntity() public method

Create a new entity from a socket and immediately assign it a world id. Requires async socket context objects with buffers pre-assigned
public NetEntity ( Socket socket, int worldID, SocketAsyncEventArgs sendEventArgs, SocketAsyncEventArgs receiveEventArgs ) : System
socket System.Net.Sockets.Socket
worldID int
sendEventArgs System.Net.Sockets.SocketAsyncEventArgs
receiveEventArgs System.Net.Sockets.SocketAsyncEventArgs
return System

SendClockSync() public method

Send a clock sync request, if there is not already one pending.
public SendClockSync ( ) : void
return void

SendPacket() public method

Enqueue a packet for sending over the wire
public SendPacket ( IPacketBase packet ) : void
packet IPacketBase
return void

Update() public method

Updates this entity, flushes and handles any pending packets in the incoming queue.
public Update ( System.TimeSpan dt ) : void
dt System.TimeSpan
return void

Property Details

BIN public_oe static_oe property

public static int BIN
return int

BOUT public_oe static_oe property

public static int BOUT
return int

IN public_oe static_oe property

public static int IN
return int

OUT public_oe static_oe property

public static int OUT
return int

m_receiveArgs protected_oe property

Async receive context object
protected SocketAsyncEventArgs,System.Net.Sockets m_receiveArgs
return System.Net.Sockets.SocketAsyncEventArgs

m_sendArgs protected_oe property

Async send context object
protected SocketAsyncEventArgs,System.Net.Sockets m_sendArgs
return System.Net.Sockets.SocketAsyncEventArgs