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
Exemple #1
0
        /// <summary>
        /// Called when a stream error occurs.
        /// </summary>
        /// <param name="Fatal">Supplies true if the error is fatal, else false
        /// if the error may be continuable.</param>
        /// <param name="ErrorCode">Supplies the error code.</param>
        /// <param name="Context">Supplies a GC handle to the NetLayerWindow
        /// object.</param>
        /// <returns>True on success, else false on failure.</returns>
        private static bool OnStreamErrorThunk(bool Fatal, UInt32 ErrorCode, IntPtr Context)
        {
            try
            {
                GCHandle       Handle = (GCHandle)Context;
                NetLayerWindow Window = (NetLayerWindow)Handle.Target;

                return(Window.OnStreamError(Fatal, ErrorCode));
            }
            catch
            {
                return(false);
            }
        }
Exemple #2
0
        /// <summary>
        /// Called when an encapsulated data packet is available to send from
        /// the NetLayerWindow connection.
        /// </summary>
        /// <param name="Data">Supplies a pointer to the data buffer.</param>
        /// <param name="Length">Supplies the length, in bytes, of the data
        /// buffer.</param>
        /// <param name="Context">Supplies a GC handle to the NetLayerWindow
        /// object.</param>
        /// <returns>True on success, else false on failure.</returns>
        private static bool OnSendThunk(IntPtr Data, IntPtr Length, IntPtr Context)
        {
            try
            {
                GCHandle       Handle     = (GCHandle)Context;
                NetLayerWindow Window     = (NetLayerWindow)Handle.Target;
                byte[]         DataBuffer = new byte[(int)Length];

                Marshal.Copy(Data, DataBuffer, 0, (int)Length);

                return(Window.OnReceive(DataBuffer));
            }
            catch
            {
                return(false);
            }
        }