Example #1
0
            /// <summary>
            /// Initializes a new instance of the <see
            /// cref="T:ExitGames.Net.Sockets.PooledReceiver.ReceiveBuffer"/> struct.
            /// </summary>
            /// <param name="e">The e.</param>
            public ReceiveBuffer(SocketReceiveEventArgs e)
            {
                this.EndPoint = e.RemoteEndPoint;
                this.Data     = new byte[e.BytesReceived];

                //›.”(e.Buffer, e.Offset, this.Data, 0, e.BytesReceived);
            }
Example #2
0
        /// <summary>
        /// Invokes the <see cref="E:ExitGames.Net.Sockets.PooledReceiver.Receive"/> event.
        /// </summary>
        /// <param name="remoteEndPoint">The remote end point.</param>
        /// <param name="buffer">The buffer.</param>
        /// <param name="offset">The offset.</param>
        /// <param name="length">The length.</param>
        private void OnReceive(EndPoint remoteEndPoint, byte[] buffer, int offset, int length)
        {
            EventHandler <SocketReceiveEventArgs> handler = Receive;

            if (handler != null)
            {
                SocketReceiveEventArgs e = new SocketReceiveEventArgs(remoteEndPoint, buffer, offset, length);
                handler(this, e);
            }
        }
Example #3
0
        /// <summary>
        /// Receives the data from the underlying <see
        /// cref="T:ExitGames.Net.Sockets.ISocketReceiver"/> and queues them to the <see
        /// cref="T:ExitGames.Concurrency.Fibers.PoolFiber"/>.
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="e">The e.</param>
        private void Receiver_OnReceive(object sender, SocketReceiveEventArgs e)
        {
            //[CompilerGenerated]
            //private sealed class #K
            //{
            //    // Fields
            //    public PooledReceiver.#D #a;
            //    public PooledReceiver #b;

            //    // Methods
            //    public void #zc()
            //    {
            //        this.#b.#b(this.#a);
            //    }
            //}

            //#K #k = new #K {
            //    #b = this,
            //    #a = new #D(args1)
            //};
            //this.Fiber.Enqueue(new Action(#k.#zc));

            try
            {
                Fiber.Enqueue(() => receiveAction(new ReceiveBuffer(e)));
            }
            catch (ThreadAbortException)
            {
                throw;
            }
            catch (OutOfMemoryException)
            {
                throw;
            }
            catch (Exception exception)
            {
                if (log.IsErrorEnabled)
                {
                    log.Error(exception);
                }
            }
        }