Esempio n. 1
0
 public void Clear()
 {
     lock (this)
     {
         Close();
         SetSocket(null);
         SendList       = null;
         currSendPacket = null;
         writeBuffer.SetPacket(null);
         recivePacket = null;
         currPackHead.Reset();
     }
 }
Esempio n. 2
0
        public void OnReciveCompleted()
        {
            readBuffer.Set(reciveSAEA.Buffer, reciveSAEA.Offset, reciveSAEA.BytesTransferred);
            while (!readBuffer.IsOver)
            {
                if (recivePacket == null)
                {
                    //读取包长度
                    if (!currPackHead.Write(readBuffer))
                    {
                        break;
                    }

                    recivePacket = new RecivePacket(currPackHead);
                    currPackHead.Reset();
                }
                else
                {
                    //读取包内容
                    recivePacket.Write(readBuffer);
                    RecivePacket packet = recivePacket;
                    if (packet != null && packet.IsWriteFull)
                    {
                        if (session != null && session.OnRecivePacket != null)
                        {
                            session.OnRecivePacket(session, packet);
                        }
                        else
                        {
                            connnectPool.OnRecive(this, packet);
                        }
                        recivePacket = null;
                    }
                }
            }
        }