Ejemplo n.º 1
0
 public void HandlePacket(EndPoint sender, IByteBuffer content)
 {
     Console.WriteLine(content.GetString(content.ArrayOffset, content.ReadableBytes, Encoding.UTF8));
     try
     {
         var identificator      = GetHeader(content);
         var DeserializedPacket = MessagePackSerializer.Deserialize(packetFactory.GetPacketById(identificator), content.GetIoBuffer().ToArray());
     }
     catch (Exception e)
     {
         Console.WriteLine(e);
     }
 }
Ejemplo n.º 2
0
        public IPacket Deserialize(IByteBuffer byteBuffer)
        {
            try
            {
                var packet     = MessagePackSerializer.Deserialize <BasicPacketCapsule>(byteBuffer.GetIoBuffer().ToArray());
                var packetType = _packetFactory.GetPacketById(packet.Identifier);

                if (packetType == null)
                {
                    _log.Warn($"Packet with identifier: [{packet.Identifier}] couldn't be found.");
                    return(null);
                }

                return(MessagePackSerializer.Deserialize(packetType, packet.Packet) as IPacket);
            }
            catch (Exception e)
            {
                _log.Error("[DESERIALIZE]", e);
                return(null);
            }
        }