Beispiel #1
0
        private void OnRecive(TCPSocketToken token, RecivePacket packet)
        {
            TCPSession sendList = clients.GetOrAdd(token, (TCPSocketToken tk) =>
            {
                TCPSession session = new TCPSession();
                session.SetToken(tk);
                return(session);
            });

            /*
             * string str = Encoding.Default.GetString(pack.Buffer, pack.HeadLen, pack.Length - pack.HeadLen);
             * if (str != StringNetPacket.TestStr)
             * {
             *  Console.WriteLine("server recive error !");
             * }
             */
            for (int i = 0; i < packet.Length - packet.HeadLen; ++i)
            {
                if (packet.Buffer[packet.HeadLen + i] != (byte)i)
                {
                    Console.WriteLine("!!!");
                }
            }
            StringNetPacket pongPacket = new StringNetPacket(1024);

            token.Session.SendPacket(pongPacket);
        }
Beispiel #2
0
 private void OnRecive(TCPSocketToken token, RecivePacket packet)
 {
     /*
      * string str = Encoding.Default.GetString(packet.Buffer, packet.HeadLen, packet.Length - packet.HeadLen);
      * if (str != StringNetPacket.TestStr)
      * {
      *  Console.WriteLine("client recive error!" + str);
      * }
      */
     for (int i = 0; i < packet.Length - packet.HeadLen; ++i)
     {
         if (packet.Buffer[packet.HeadLen + i] != (byte)i)
         {
             Console.WriteLine("!!!");
         }
     }
     SendPack(token.Session);
 }
 private void Mavlink_PacketReceived(object sender, MavlinkPacket e)
 {
     RecivePacket?.Invoke(e);
 }