Example #1
0
        private async void OnNetworkReceive(NetPeer peer, NetPacketReader reader, DeliveryMethod clientDeliveryMethod)
        {
            NList      msg     = ProtoUtils.Deserialize <NList>(reader.GetBytesWithLength());
            UdpSession session = null;

            if (_Sessions.TryGetValue(peer.Id, out session))
            {
                await session.IncomingMessage(msg);
            }

            _NetManager.TriggerUpdate();
            reader.Recycle();
        }
Example #2
0
        protected override void Decode(IChannelHandlerContext context, IByteBuffer message, List <object> output)
        {
            Contract.Requires(context != null);
            Contract.Requires(message != null);
            Contract.Requires(output != null);
            Contract.Requires(message.ReadableBytes > 0);

            try
            {
                Span <byte> spby = ((Span <byte>)message.Array).Slice(message.ArrayOffset, message.ReadableBytes);

                T decoded = ProtoUtils.Deserialize <T>(spby.ToArray());

                if (decoded != null)
                {
                    output.Add(decoded);
                }
            }
            catch (Exception exception)
            {
                throw new CodecException(exception);
            }
        }