Enqueue() public method

public Enqueue ( byte buffer, int offset, int size ) : void
buffer byte
offset int
size int
return void
Example #1
0
        private void Receive_Process(SocketAsyncEventArgs e)
        {
            int byteCount = e.BytesTransferred;

            if (e.SocketError != SocketError.Success || byteCount <= 0)
            {
                Dispose(false);
                return;
            }

            m_NextCheckActivity = DateTime.Now + TimeSpan.FromMinutes(1.2);

            byte[] buffer = m_RecvBuffer;

            if (m_Encoder != null)
            {
                m_Encoder.DecodeIncomingPacket(this, ref buffer, ref byteCount);
            }

            lock (m_Buffer)
                m_Buffer.Enqueue(buffer, 0, byteCount);

            m_MessagePump.OnReceive(this);

            lock ( m_AsyncLock ) {
                m_AsyncState &= ~AsyncState.Pending;
            }
        }
Example #2
0
        private void Receive_Process(SocketAsyncEventArgs e)
        {
            int byteCount = e.BytesTransferred;

            if (e.SocketError != SocketError.Success || byteCount <= 0)
            {
                Dispose(false);
                return;
            }

            m_NextCheckActivity = DateTime.UtcNow + TimeSpan.FromMinutes(1.2);

            byte[] buffer = m_RecvBuffer;

            if (m_Encoder != null)
            {
                m_Encoder.DecodeIncomingPacket(this, ref buffer, ref byteCount);
            }

            //If we support encryption, then it is possible that the client was DISPOSED at this point.
            if (!m_Disposing)
            {
                lock (m_Buffer)
                    m_Buffer.Enqueue(buffer, 0, byteCount);

                m_MessagePump.OnReceive(this);

                lock (m_AsyncLock)
                    m_AsyncState &= ~AsyncState.Pending;
            }
        }
Example #3
0
        private void OnReceive(IAsyncResult asyncResult)
        {
            try
            {
                Socket s = (Socket)asyncResult.AsyncState;

                int byteCount = s.EndReceive(asyncResult);

                if (byteCount > 0)
                {
                    m_NextCheckActivity = Core.TickCount + 90000;

                    byte[] buffer;

                    lock (m_AsyncLock)
                        buffer = m_RecvBuffer;

                    if (PacketEncryptor != null)
                    {
                        PacketEncryptor.DecryptIncomingPacket(this, ref buffer, ref byteCount);
                    }

                    if (PacketEncoder != null)
                    {
                        PacketEncoder.DecodeIncomingPacket(this, ref buffer, ref byteCount);
                    }

                    lock (m_Buffer)
                        m_Buffer.Enqueue(buffer, 0, byteCount);

                    m_MessagePump.OnReceive(this);

                    lock (m_AsyncLock)
                    {
                        m_AsyncState &= ~AsyncState.Pending;

                        if ((m_AsyncState & AsyncState.Paused) == 0)
                        {
                            try
                            {
                                InternalBeginReceive();
                            }
                            catch (Exception ex)
                            {
                                TraceException(ex);
                                Dispose(false);
                            }
                        }
                    }
                }
                else
                {
                    Dispose(false);
                }
            }
            catch
            {
                Dispose(false);
            }
        }
Example #4
0
        private void OnReceive(IAsyncResult asyncResult)
        {
            Socket s = (Socket)asyncResult.AsyncState;

            try
            {
                int byteCount = s.EndReceive(asyncResult);

                if (byteCount > 0)
                {
                    m_NextCheckActivity = DateTime.Now + TimeSpan.FromMinutes(1.2);

                    byte[] buffer = m_RecvBuffer;

                    if (m_Encoder != null)
                    {
                        m_Encoder.DecodeIncomingPacket(this, ref buffer, ref byteCount);
                    }

                    lock (m_Buffer)
                        m_Buffer.Enqueue(buffer, 0, byteCount);

                    m_MessagePump.OnReceive(this);

                    lock (m_AsyncLock)
                    {
                        m_AsyncState &= ~AsyncState.Pending;

                        if ((m_AsyncState & AsyncState.Paused) == 0)
                        {
                            try
                            {
                                InternalBeginReceive();
                            }
                            catch (Exception ex)
                            {
                                TraceException(ex);
                                Dispose(false);
                            }
                        }
                    }
                }
                else
                {
                    Dispose(false);
                }
            }
            catch
            {
                Dispose(false);
            }
        }
Example #5
0
        private void OnReceive(IAsyncResult asyncResult)
        {
            lock (this)
            {
                if (m_Socket == null)
                {
                    return;
                }

                try
                {
                    int byteCount = m_Socket.EndReceive(asyncResult);

                    if (byteCount > 0)
                    {
                        m_NextCheckActivity = DateTime.Now + TimeSpan.FromMinutes(1.2);

                        byte[] buffer = m_RecvBuffer;

                        if (m_Encoder != null)
                        {
                            m_Encoder.DecodeIncomingPacket(this, ref buffer, ref byteCount);
                        }

                        m_Buffer.Enqueue(buffer, 0, byteCount);

                        m_Incoming += byteCount;

                        m_NetServer.OnReceive(this, byteCount);
                    }
                    else
                    {
                        Dispose(false);
                    }
                }
                catch (Exception ex)
                {
                    TraceException(ex);
                    Dispose(false);
                }
            }
        }
Example #6
0
        private void OnReceive(IAsyncResult asyncResult)
        {
            lock (this)
            {
                if (m_Socket == null)
                {
                    return;
                }

                try
                {
                    int byteCount = m_Socket.EndReceive(asyncResult);

                    if (byteCount > 0)
                    {
                        m_NextCheckActivity = Core.Now + TimeSpan.FromMinutes(1.2);

                        byte[] buffer = m_RecvBuffer;

                        if (m_Encoder != null)
                        {
                            m_Encoder.DecodeIncomingPacket(this, ref buffer, ref byteCount);
                        }

                        m_Buffer.Enqueue(buffer, 0, byteCount);

                        m_MessagePump.OnReceive(this);
                    }
                    else
                    {
                        Dispose(false);
                    }
                }
                catch                 // ( Exception ex )
                {
                    //Console.WriteLine(ex);
                    Dispose(false);
                }
            }
        }
Example #7
0
		private void Receive_Process( SocketAsyncEventArgs e )
		{
			//Plume : Net 4
            /*int byteCount = e.BytesTransferred;

			if ( e.SocketError != SocketError.Success || byteCount <= 0 ) {
				Dispose( false );
				return;
			}

			m_NextCheckActivity = DateTime.Now + TimeSpan.FromMinutes( 1.2 );

			byte[] buffer = m_RecvBuffer;

			if ( m_Encoder != null )
				m_Encoder.DecodeIncomingPacket( this, ref buffer, ref byteCount );

			lock ( m_Buffer )
				m_Buffer.Enqueue( buffer, 0, byteCount );

			m_MessagePump.OnReceive( this );

			lock ( m_AsyncLock ) {
				m_AsyncState &= ~AsyncState.Pending;*/

            try
			{
				if (!m_Disposing)
				{
                    int byteCount = e.BytesTransferred;
                    if ( e.SocketError != SocketError.Success || byteCount <= 0 )
                    {
						Dispose( false );
						return;
					}
                    else
                    {
                        m_NextCheckActivity = DateTime.Now + TimeSpan.FromMinutes( 1.2 );
                        byte[] buffer = m_RecvBuffer;
                        if ( m_Encoder != null )
							m_Encoder.DecodeIncomingPacket( this, ref buffer, ref byteCount );
                if (m_Buffer != null)
                        {
                        	lock ( m_Buffer )
								m_Buffer.Enqueue( buffer, 0, byteCount );
                if (!m_Disposing)
                            {
								m_MessagePump.OnReceive( this );
                                lock ( m_AsyncLock ) 
                                {
									m_AsyncState &= ~AsyncState.Pending;
								}
                            }
                        }
                    }
				}
 			}
			catch (Exception ex)
			{
				Console.WriteLine("Exception on Netstate in Receive_Process");
				Console.WriteLine(ex.Message);
				Console.WriteLine(ex.StackTrace);
			}
			}