C# Class NWN.NetLayerWindow

This class wraps AuroraServerNetLayer.dll's reliable datagram protocol for use by managed code. A typical user of the class must use the following events and methods: NetLayerWindow.Connect() is called when the application wishes to open a connection. Keep alive traffic and other periodic events are started at this time. NetLayerWindow.SendPacket() is called when the application wishes to send an application-specific packet to the remote endpoint. NetLayerWindow.PacketReceiveEvent is fired when application-specific data is received (sequenced, in-stream-order) from the remote endpoint. NetLayerWindow.ReceivePacket() is called when NetLayerWindow packet data (raw network traffic) is received from the remote endpoint. This data usually comes directly from a network socket. NetLayerWindow.PacketSendEvent is fired when NetLayerWindow packet data (raw network traffic) is ready to be sent to the remote endpoint. This data is usually sent directly to a network socket. To break a connection, the NetLayerWindow object should be disposed and a new NetLayerWindow object created. Actual responsibility for informing the other party that a connection is ready to be established (and transmitting and receiving raw network data) is the user's responsibility, and is outside the scope of the NetLayerWindow object itself. This decouples the NetLayerWindow object from the raw details of how network traffic is sent or received. The user must only call the NetLayerWindow object on the main thread, which must run a message loop (for the timer). User events are only raised when a call to the NetLayerWindow object is outstanding, or the internal timer has been fired by the user's message loop.
Inheritance: IDisposable
Afficher le fichier Open project: ALandFarAway/ALFA-Base-Resources Class Usage Examples

Méthodes publiques

Свойство Type Description
StreamErrorEvent EventHandler

Méthodes publiques

Méthode Description
Connect ( ) : void

Enable the connection for use.

Dispose ( ) : void

Dispose the object.

NetLayerWindow ( ) : System

Create a new NetLayerWindow object.

ReceivePacket ( byte Data, int Offset ) : void

Receive a packet from the network. This should be invoked on the main thread.

SendPacket ( byte Data, bool FlushNagle ) : void

Send a packet. This should be invoked on the main thread.

Private Methods

Méthode Description
AuroraServerNetLayerCreate ( IntPtr ExistingInstance, CONNECTION_CALLBACKS Callbacks ) : IntPtr
AuroraServerNetLayerDestroy ( IntPtr Connection ) : bool
AuroraServerNetLayerQuery ( IntPtr Connection, NETLAYERWINDOW_INFO_CLASS InfoClass, UInt32 InfoBufferSize, UInt32 &ReturnLength, IntPtr InfoBuffer ) : bool
AuroraServerNetLayerReceive ( IntPtr Connection, IntPtr Data, IntPtr Length ) : bool
AuroraServerNetLayerSend ( IntPtr Connection, IntPtr Data, IntPtr Length, bool HighPriority, bool FlushNagle ) : bool
AuroraServerNetLayerTimeout ( IntPtr Connection ) : UInt32
Dispose ( bool Disposing ) : void

Dispose the object.

OnReceive ( byte Data ) : bool

Called when a data packet is available on the NetLayerWindow connection.

OnReceiveThunk ( IntPtr Data, IntPtr Length, IntPtr Context ) : bool

Called when a data packet is available on the NetLayerWindow connection.

OnSend ( byte Data ) : bool

Called when a data packet is available to send from the NetLayerWindow connection.

OnSendThunk ( IntPtr Data, IntPtr Length, IntPtr Context ) : bool

Called when an encapsulated data packet is available to send from the NetLayerWindow connection.

OnStreamError ( bool Fatal, UInt32 ErrorCode ) : bool

Called when a stream error is raised on the NetLayerWindow connection.

OnStreamErrorThunk ( bool Fatal, UInt32 ErrorCode, IntPtr Context ) : bool

Called when a stream error occurs.

WindowTimer_Tick ( object sender, EventArgs e ) : void

Called by the timer package when the window timer elapses, on the main thread.

Method Details

Connect() public méthode

Enable the connection for use.
public Connect ( ) : void
Résultat void

Dispose() public méthode

Dispose the object.
public Dispose ( ) : void
Résultat void

NetLayerWindow() public méthode

Create a new NetLayerWindow object.
public NetLayerWindow ( ) : System
Résultat System

ReceivePacket() public méthode

Receive a packet from the network. This should be invoked on the main thread.
public ReceivePacket ( byte Data, int Offset ) : void
Data byte Supplies the packet data.
Offset int Supplies the offset into the packet data to /// hand off to the NetLayerWindow package (zero if the entire data /// buffer is in NetLayerWindow format with no application specific /// header prepended).
Résultat void

SendPacket() public méthode

Send a packet. This should be invoked on the main thread.
public SendPacket ( byte Data, bool FlushNagle ) : void
Data byte Supplies the data packet to send.
FlushNagle bool Supplies true if the send request should /// be expedited at the cost of bandwidth efficiency, by flushing any /// pending Nagle queue immediately.
Résultat void

Property Details

StreamErrorEvent public_oe property

Event registration for a stream error notification. The event handler should take appropriate streams to log the error, and if Fatal is true, close down the connection as appropriate.
public EventHandler StreamErrorEvent
Résultat EventHandler