/// <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); } }
/// <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); } }