Exemplo n.º 1
0
        private void AddPongEntry(PongEntry newEntry)
        {
            var oldEntry = m_pongHistory[pongHistoryCount - 1];

            for (int i = pongHistoryCount - 1; i > 0; i--)
            {
                m_pongHistory[i] = m_pongHistory[i - 1];
            }

            m_pongHistory[0] = newEntry;

            int oldIndex = Array.BinarySearch(m_pongHistorySorted, oldEntry);

            if (oldIndex >= 0)
            {
                NetUtility.ReplaceSortedItem(m_pongHistorySorted, oldIndex, newEntry);
            }
            else
            {
                string pongHistoryValues = "";
                foreach (var pong in m_pongHistorySorted)
                {
                    pongHistoryValues += "\n (" + pong + ")";
                }

                Log.Error(LogFlags.Socket, "Can't find pong entry (", oldEntry, ") in sorted history: ", pongHistoryValues);
            }

            UpdateValuesBasedOnPongHistory();
        }