public void parsePacket(NetworkMessage nmsg)
        {
            int packetType = nmsg.ReadByte();

            if (PacketParsers.ContainsKey(packetType))
            {
                PacketParser  pp      = PacketParsers[packetType];
                Packet        p       = pp.parser(nmsg);
                ProtocolEvent handler = PacketHandlers[packetType];
                if (handler != null && p != null)
                {
                    handler.Invoke(p);
                }

                /*
                 * string m = "Parsing packet 0x" + packetType.ToString("X2") + " '" + ph.name + "'";
                 * if (p != null)
                 *  m += "<pre>" + p.ToString() + "</pre>";
                 * Log.Debug(m);
                 */
                if (!nmsg.ReadAllData())
                {
                    parsePacket(nmsg);
                }
            }
            else
            {
                Log.Warning("Unknown packet type parsed 0x" + packetType.ToString("X2"), this);
            }
        }
Beispiel #2
0
 protected void TriggerEvent()
 {
     ProtocolEvent?.Invoke(this, EventArgs.Empty);
 }
Beispiel #3
0
 internal void FireProtocolEvent(GenericParsedEventArgs args) => ProtocolEvent?.Invoke(this, args);