Beispiel #1
0
        private void ReceiveCallback(IAsyncResult ar)
        {
            //		if ( ar.IsCompleted )
            //		{
            try
            {
                NetReadBuffer buffer       = m_Readbuffer;
                int           nReadDataLen = m_CliSocket.EndReceive(ar);

                if (nReadDataLen == 0)
                {
                    ReinitSocket();
                    PostDisconnectMsg();
                }
                else
                {
                    buffer.setMaxDataPostion(buffer.getMaxDataPostion() + nReadDataLen);
                    DecodeMsg_Cumulative();
                    m_Readbuffer.Settle();

                    BeginRecv();
                }
            }
            catch (Exception e)
            {
                //Debug.LogError( "Recieve callback exception " + e.ToString() );
                Debug.LogException(e);
                ReinitSocket();
                PostDisconnectMsg();
            }
            //		}
        }
Beispiel #2
0
        public void InitServerConnect()
        {
            m_ReadMsgQueue  = new Queue <INetWorkMessage>();
            m_WriteMsgQueue = new Queue <INetWorkMessage>();
            //writeDone = new Mutex(false);
            m_Readbuffer  = new NetReadBuffer(s_nReadBufferSize);
            m_Writebuffer = new NetWriteBuffer(s_nWriteBufferSize);

            m_Readbuffer.Clear();
            m_Writebuffer.Clear();
        }