示例#1
0
        /**
         * Disconnect from the network.
         */
        public void Disconnect()
        {
            if (ProtocolLog.NodeLog.Enabled)
            {
                ProtocolLog.Write(ProtocolLog.NodeLog, String.Format(
                                      "Called Node.Disconnect: {0}", this.Address));
            }
            bool changed_state = false;

            try {
                SetConState(Node.ConnectionState.Leaving, out changed_state);
                if (changed_state)
                {
                    ProtocolLog.WriteIf(ProtocolLog.NodeLog, String.Format(
                                            "[Connect: {0}] deactivating task queue", _local_add));
                    _task_queue.IsActive = false;
                    Interlocked.Exchange(ref _send_pings, 0);
                    _connection_table.Close();
                }
            }
            finally {
                if (changed_state)
                {
                    SendStateChange(Node.ConnectionState.Leaving);
                }
            }
        }