Example #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();
            }
            //		}
        }
Example #2
0
 public void BeginRecv()
 {
     try
     {
         m_CliSocket.BeginReceive(m_Readbuffer.getRealBuffer(),
                                  m_Readbuffer.getMaxDataPostion(), m_Readbuffer.getCapability(), 0, new AsyncCallback(ReceiveCallback), this);
     }
     catch (Exception e)
     {
         Debug.LogException(e);
         //Debug.LogError( "Begin recieve msg exception " + e.ToString());
     }
 }