Esempio n. 1
0
 public void SendMessage(IMessage msg)
 {
     lock (MessageQueueLocker)
     {
         NetOutgoingMessage om = client.CreateMessage();
         om.Write(msg.Id);
         msg.Write(om);
         if (om.LengthBytes > MaxPacketSize)
         {
             var id = client.UniqueIdentifier;
             lock (PacketMessageDictionaryLocker)
             {
                 PacketMessageDictionary[id] = om;
             }
             var packetMsg = new SendPacketMessage()
             {
                 UniqueIdentifier    = id,
                 TargetSize          = (om.LengthBytes + MaxPacketSize - 1) / MaxPacketSize,
             };
             SendMessage(packetMsg);
         }
         else
         {
             MessageQueue.Enqueue(new NetClientMsg(om, NetDeliveryMethod.Unreliable));
         }
     }
 }
Esempio n. 2
0
        private void OnSendPacketMessage(NetBuffer msg, NetConnection conn)
        {
            long id         = MessageRecvId;
            var packetMsg   = new SendPacketMessage();
            packetMsg.Read(msg);


            lock(SendPacketMessageRecvDictionaryLocker)
            {
                SendPacketMessageRecvDictionary[id] = new PacketNetBuffer(packetMsg.TargetSize, conn);
            }

            var rspMsg = new SendPacketMessageRecv()
            {
                UniqueIdentifier    = packetMsg.UniqueIdentifier,
                MessagePacketId     = id,
            };
            SendMessage(rspMsg, conn);
        }