Exemple #1
0
        public void Shutdown()
        {
            //If already in Shuttingdown state, or Idle, no need to do through shutdown again
            if (m_syncState == SyncConnectorState.ShuttingDown || m_syncState == SyncConnectorState.Idle)
            {
                return;
            }

            m_syncState = SyncConnectorState.ShuttingDown;

            // Cleanup on a worker thread because it will usually kill this thread that's currently running
            // (either the m_send_loop or m_rcvLoop)
            System.Threading.ThreadPool.QueueUserWorkItem(delegate
            {
                m_log.WarnFormat("{0}: Shutting down connection", LogHeader);

                // Close the connection
                m_tcpConnection.Client.Close();
                m_tcpConnection.Close();

                m_regionSyncModule.CleanupAvatars();

                RequestSendRecvLoopsStop();
                // Abort receive and send loop
                //m_rcvLoop.Abort();
                //m_send_loop.Abort();
                m_rcvLoop.Join();
                m_send_loop.Join();

                m_syncState     = SyncConnectorState.Idle;
                m_tcpConnection = null;
            });
        }
Exemple #2
0
 /// <summary>
 /// The constructor that will be called when a SyncConnector is created actively: it is created to send connection request to a remote listener
 /// </summary>
 /// <param name="connectorNum"></param>
 /// <param name="listenerInfo"></param>
 public SyncConnector(int connectorNum, RegionSyncListenerInfo listenerInfo, RegionSyncModule syncModule)
 {
     m_remoteListenerInfo = listenerInfo;
     m_connectorNum       = connectorNum;
     m_regionSyncModule   = syncModule;
     lastStatTime         = DateTime.Now;
     m_syncState          = SyncConnectorState.Initialization;
     m_log = LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
 }
Exemple #3
0
 /// <summary>
 /// The constructor that will be called when a SyncConnector is created passively: a remote SyncConnector has initiated the connection.
 /// </summary>
 /// <param name="connectorNum"></param>
 /// <param name="tcpclient"></param>
 public SyncConnector(int connectorNum, TcpClient tcpclient, RegionSyncModule syncModule)
 {
     m_tcpConnection    = tcpclient;
     m_connectorNum     = connectorNum;
     m_regionSyncModule = syncModule;
     lastStatTime       = DateTime.Now;
     m_syncState        = SyncConnectorState.Initialization;
     m_log = LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
 }
Exemple #4
0
 //Connect to the remote listener
 public bool Connect()
 {
     m_tcpConnection = new TcpClient();
     try
     {
         m_tcpConnection.Connect(m_remoteListenerInfo.Addr, m_remoteListenerInfo.Port);
         m_syncState = SyncConnectorState.Syncing;
     }
     catch (Exception e)
     {
         m_log.WarnFormat("{0} [Start] Could not connect to RegionSyncModule at {1}:{2}", LogHeader, m_remoteListenerInfo.Addr, m_remoteListenerInfo.Port);
         m_log.Warn(e.Message);
         return(false);
     }
     return(true);
 }
        public void Shutdown()
        {
            //If already in Shuttingdown state, or Idle, no need to do through shutdown again
            if (m_syncState == SyncConnectorState.ShuttingDown || m_syncState == SyncConnectorState.Idle)
                return;

            m_syncState = SyncConnectorState.ShuttingDown;

            // Cleanup on a worker thread because it will usually kill this thread that's currently running
            // (either the m_send_loop or m_rcvLoop)
            System.Threading.ThreadPool.QueueUserWorkItem(delegate
            {
                m_log.WarnFormat("{0}: Shutting down connection", LogHeader);

                // Close the connection
                m_tcpConnection.Client.Close();
                m_tcpConnection.Close();

                m_regionSyncModule.CleanupAvatars();

                RequestSendRecvLoopsStop();
                // Abort receive and send loop
                //m_rcvLoop.Abort();
                //m_send_loop.Abort();
                m_rcvLoop.Join();
                m_send_loop.Join();

                m_syncState = SyncConnectorState.Idle;
                m_tcpConnection = null;
            });
        }
 //Connect to the remote listener
 public bool Connect()
 {
     m_tcpConnection = new TcpClient();
     try
     {
         m_tcpConnection.Connect(m_remoteListenerInfo.Addr, m_remoteListenerInfo.Port);
         m_syncState = SyncConnectorState.Syncing;
     }
     catch (Exception e)
     {
         m_log.WarnFormat("{0} [Start] Could not connect to RegionSyncModule at {1}:{2}", LogHeader, m_remoteListenerInfo.Addr, m_remoteListenerInfo.Port);
         m_log.Warn(e.Message);
         return false;
     }
     return true;
 }
 /// <summary>
 /// The constructor that will be called when a SyncConnector is created actively: it is created to send connection request to a remote listener
 /// </summary>
 /// <param name="connectorNum"></param>
 /// <param name="listenerInfo"></param>
 public SyncConnector(int connectorNum, RegionSyncListenerInfo listenerInfo, RegionSyncModule syncModule)
 {
     m_remoteListenerInfo = listenerInfo;
     m_connectorNum = connectorNum;
     m_regionSyncModule = syncModule;
     lastStatTime = DateTime.Now;
     m_syncState = SyncConnectorState.Initialization;
     m_log = LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
 }
 /// <summary>
 /// The constructor that will be called when a SyncConnector is created passively: a remote SyncConnector has initiated the connection.
 /// </summary>
 /// <param name="connectorNum"></param>
 /// <param name="tcpclient"></param>
 public SyncConnector(int connectorNum, TcpClient tcpclient, RegionSyncModule syncModule)
 {
     m_tcpConnection = tcpclient;
     m_connectorNum = connectorNum;
     m_regionSyncModule = syncModule;
     lastStatTime = DateTime.Now;
     m_syncState = SyncConnectorState.Initialization;
     m_log = LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
 }