Exemple #1
0
 private void ProcessReceivedMessage(INetUser client, byte[] messageBuffer)
 {
     using (INetPacketStream packet = _packetParser.PacketProcessor.CreatePacket(messageBuffer))
     {
         client.HandleMessage(packet);
     }
 }
        /// <inheritdoc />
        public void DispatchMessage(INetUser client, NetDataToken token)
        {
            var bufferSize = this.PacketProcessor.IncludeHeader ? this.PacketProcessor.HeaderSize + token.MessageSize.Value : token.MessageSize.Value;
            var buffer     = new byte[bufferSize];

            if (this.PacketProcessor.IncludeHeader)
            {
                Array.Copy(token.HeaderData, 0, buffer, 0, this.PacketProcessor.HeaderSize);
                Array.Copy(token.MessageData, 0, buffer, this.PacketProcessor.HeaderSize, token.MessageSize.Value);
            }
            else
            {
                Array.Copy(token.MessageData, 0, buffer, 0, token.MessageSize.Value);
            }

            Task.Run(() =>
            {
                using (INetPacketStream packet = this.PacketProcessor.CreatePacket(buffer))
                    client.HandleMessage(packet);
            });
        }