Пример #1
0
        ///////////////////////////////////////////////////////////
        // Sending messages out to the other side of the connection
        ///////////////////////////////////////////////////////////
        // Send messages from the update Q as fast as we can DeQueue them
        // *** This is the main send loop thread for each connected client
        private void SendLoop()
        {
            try
            {
                //while (true)
                while (!_shouldStopSend && m_tcpConnection.Connected)
                {
                    SyncMsg msg = m_outQ.Dequeue();

                    if (msg != null)
                    {
                        if (m_collectingStats)
                        {
                            currentQueue.Event(-1);
                        }
                        // Do any conversion if it was not done earlier (on a friendlier thread)
                        if (msg.ConvertOut(m_regionSyncModule))
                        {
                            Send(msg);
                        }
                    }
                }
            }
            catch (Exception e)
            {
                m_log.ErrorFormat("{0} has disconnected: {1} (SendLoop)", description, e);
            }
            Shutdown();
        }