Ejemplo n.º 1
0
        public MessageStatistics BuildMessageStatistics()
        {
            lock (_syncStat)
            {
                var reliableSet = new HashSet <ushort>(ReliableMessages);
                return(new MessageStatistics
                {
                    Sent = MessagesSentCount
                           .Select(item => new Tuple <ushort, bool, int>(item.Key, reliableSet.Contains(item.Key), item.Value))
                           .OrderBy(t => t.Item1).ToList(),

                    Received = MessagesReceivedCount
                               .Select(item => new Tuple <ushort, bool, int>(item.Key, reliableSet.Contains(item.Key), item.Value))
                               .OrderBy(t => t.Item1).ToList(),
                });
            }
        }
Ejemplo n.º 2
0
        public void TrackReceivedMessage(ushort operationCode, int messageLength, bool isReliable)
        {
            lock (_syncStat)
            {
                var messageOperationCode = operationCode;
                if (!MessagesReceivedCount.ContainsKey(messageOperationCode))
                {
                    MessagesReceivedCount.Add(messageOperationCode, 1);
                }
                else
                {
                    MessagesReceivedCount[messageOperationCode]++;
                }

                TotalTrafficReceived += messageLength;

                if (isReliable)
                {
                    AddReliable(messageOperationCode);
                }
            }
        }