Esempio n. 1
0
 protected override void StartReceive(Socket client, byte[] buffer, int offset, int count)
 {
     if (count >= 8)
     {
         //检查握手包(8字节)
         int code = buffer[offset + 2] + (buffer[offset + 3] << 8);
         if (code == 99)
         {
             ISession session = m_sessionFactory.CreateSession(client);
             if (session != null)
             {
                 var handR = AmfCodec.Encode("handR", new object[] {
                     serverVer,      //版本号
                     new object[]{session.ConnectID, serverVer} //用于加密数组
                 });
                 session.SendAsync(handR);
                 session.ReceiveAsync(buffer, offset + 8, count - 8);
                 return;
             }
         }
     }
     //断开
     client.SafeClose();
 }