public static EventData CreateEventData(ServerPacket serverPacket)
        {
            var       reader    = serverPacket.arrByteReader;
            EventData eventData = new EventData()
            {
                Code = serverPacket.Code,
            };
            Dictionary <byte, object> parameters = new Dictionary <byte, object>();

            eventData.Parameters = parameters;
            while (reader.ReadLen < serverPacket.len)
            {
                byte   key   = reader.ReadByte();
                string value = reader.ReadUTF8String();
                parameters.Add(key, value);
            }

            return(eventData);
        }
Esempio n. 2
0
        public static void DistributePeer(ServerPacket serverPacket, ClientPeer peer)
        {
            try
            {
                switch (serverPacket.CType)
                {
                case ServerPacket.CodeType.OperationCode:
                    peer.PeerListener.OnOperationResponse(OperationResponseTool.CreateOperationResponse(serverPacket));
                    break;

                case ServerPacket.CodeType.EventCode:
                    peer.PeerListener.OnEvent(EventDataTool.CreateEventData(serverPacket));
                    break;
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }