Esempio n. 1
0
        public override IByteBuffer WriteHeader(IByteBuffer header, PacketRegistration packet, IByteBuffer data)
        {
            IByteBuffer opcodeBuffer = Unpooled.Buffer(5);

            ByteBufUtils.WriteVarInt(opcodeBuffer, packet.Opcode);
            ByteBufUtils.WriteVarInt(header, opcodeBuffer.ReadableBytes + data.ReadableBytes);
            opcodeBuffer.Release();
            ByteBufUtils.WriteVarInt(header, packet.Opcode);
            return(header);
        }
Esempio n. 2
0
        public override PacketRegistration GetPacketRegistration(IPacket packet)
        {
            PacketRegistration reg = outboundCodecs.Find(packet);

            if (reg == null)
            {
                Logger.Warn("No codec to write: " + packet.GetType().Name + " in " + Name);
            }
            return(reg);
        }
Esempio n. 3
0
        public void Register <T>(byte id, Func <T> func) where T : Packet
        {
            var regstration = new PacketRegistration <T>(id, func);
            var ids         = this.Ids;
            var types       = this.Types;

            lock (ids)
            {
                lock (types)
                {
                    var type = typeof(T);
                    ids[id]     = regstration;
                    types[type] = regstration;
                }
            }
        }