Beispiel #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();
        }
Beispiel #2
0
        private void CollectReceiveStat(string type, int length)
        {
            lock (stats)
            {
                if (m_collectingStats)
                {
                    msgsIn.Event();
                    bytesIn.Event(length);

                    SyncConnectorStat msgStat;
                    if (!m_packetTypesRcvd.TryGetValue(type, out msgStat))
                    {
                        msgStat = new SyncConnectorStat(
                            "DSG_Msgs_Typ_Rcvd|" + description + "|" + type, // shortName
                            type + "_Rcvd",                                  // name
                            "connector DSG messages of type " + type,        // description
                            " messages",                                     // unit
                            m_regionSyncModule.Scene.Name,                   // region
                            m_connectorNum,                                  // connectornum
                            m_regionSyncModule.ActorID,                      // myActorID
                            otherSideRegionName,                             // otherSideRegionName
                            otherSideActorID,                                // otherSideActorID
                            type                                             // messageType
                            );
                        StatsManager.RegisterStat(msgStat);
                        m_packetTypesRcvd.Add(type, msgStat);
                    }
                    msgStat.Event();
                }
            }
        }