Esempio n. 1
0
 public void ProcessData(byte[] data)
 {
     Packet.RecvPacketHandler handler = Packet.RecvPacketHandlers.GetHandler(data[2]);
     if (handler != null)
     {
         Packet.OnPacketReceive pHandlerMethod = handler.OnReceive;
         try
         {
             pHandlerMethod(this, data);
             ConnectionAlive();
         }
         catch (Exception e)
         {
             Output.WriteLine("Connection::ProcessData - catch exception: " + e.ToString());
             Close();
         }
         //set new time for last recved packet
         //LastRecv = DateTime.UtcNow.TimeOfDay;
     }
     else
     {
         Output.WriteLine("Connection::ProcessData " + "Wrong packet - close connection");
         Close();
     }
 }
Esempio n. 2
0
        public static RecvPacketHandler GetHandler(byte packetID)
        {
            RecvPacketHandler pHandler = null;

            try
            {
                pHandler = packetHandlers[packetID];
            }
            catch (Exception)
            {
                Output.WriteLine("RecvPacketHandlers::GetHandler Couldn't find a packet handler for packet with ID: " + packetID.ToString());
            }
            return(pHandler);
        }