Exemplo n.º 1
0
        private void OnPacketMessage(NetBuffer msg)
        {
            var packetMsg = new PacketMessage();

            packetMsg.Read(msg);

            long id = packetMsg.MessagePacketId;

            if (SendPacketMessageRecvDictionary.ContainsKey(id))
            {
                PacketNetBuffer packet = null;
                lock (SendPacketMessageRecvDictionaryLocker)
                {
                    if (SendPacketMessageRecvDictionary.ContainsKey(id))
                    {
                        packet = SendPacketMessageRecvDictionary[id];
                    }
                }
                if (packet != null)
                {
                    packet.Add(packetMsg);
                    if (packet.IsComplete)
                    {
                        var ms = packet.ToBuffer();
                        lock (SendPacketMessageRecvDictionaryLocker)
                        {
                            SendPacketMessageRecvDictionary.Remove(id);
                        }
                        lock (AlreadyMessageQueueLocker)
                        {
                            OnDataMessage(this, ms, packet.SendConnection);
                        }
                    }
                }
            }
        }