Ejemplo n.º 1
0
        public void Update(TimeSpan timeSinceLastUpdate)
        {
            List <NetworkClient> keys = bufferedMessages.Keys.ToList();

            foreach (var key in keys)
            {
                BufferedNetworkMessage bMessage = bufferedMessages[key];
                if (DateTime.Now - bMessage.FirstMessageDataTime > bMessage.MaxBufferTime - timeSinceLastUpdate)
                {
                    messagesToSend.Add(bMessage);
                    bufferedMessages.Remove(key);
                }
            }

            foreach (var message in messagesToSend)
            {
                client.NetworkManager.SendMessage(message.Destination, message.Message);
            }

            messagesToSend.Clear();
        }
Ejemplo n.º 2
0
        public void BufferMessage(NetworkClient client, NetworkMessage message)
        {
            if (!bufferedMessages.ContainsKey(client))
            {
                bufferedMessages.Add(client, new BufferedNetworkMessage()
                {
                    Destination = client
                });
            }

            if (bufferedMessages[client].Message.Length + message.Length > this.client.ClientProperties.MaxMessageDataSize)
            {
                messagesToSend.Add(bufferedMessages[client]);
                bufferedMessages[client] = new BufferedNetworkMessage()
                {
                    Destination = client
                };
            }

            bufferedMessages[client].AppendMessageData(message.Data);
        }