Disconnect a client.

        :param sid: The session id of the client to close. If this parameter
                    is not given, then all clients are closed.
517550
def disconnect(self, sid=None):
        
        if sid is not None:
            try:
                socket = self._get_socket(sid)
            except KeyError:  # pragma: no cover
                # the socket was already closed or gone
                pass
            else:
                socket.close()
                del self.sockets[sid]
        else:
            for client in six.itervalues(self.sockets):
                client.close()
            self.sockets = {}
1059905
def disconnect(self, *args, **kwargs):
        
        quit_message = "%s %s" % (settings.GNOTTY_VERSION_STRING,
                                  settings.GNOTTY_PROJECT_URL)
        self.client.connection.quit(quit_message)
        super(IRCNamespace, self).disconnect(*args, **kwargs)
261031
def disconnect(self):
        
        try: # connection may already be disconnected, so catch exceptions
            self.socket.shutdown(socket.SHUT_RDWR) # a proper disconnect
        except socket.error:
            pass
        self.socket.close()
        self.connected = False
71683
public function kill_session($sid) {
        if (!$this->servers) {
            return;
        }

        // Go through the list of all servers because
        // we do not know where the session handler put the
        // data.

        foreach ($this->servers as $server) {
            list($host, $port) = $server;
            $memcached = new \Memcached();
            $memcached->addServer($host, $port);
            $memcached->delete($this->prefix . $sid);
            $memcached->quit();
        }
    }
281848
private void disconnect(FTPClient client) throws IOException {
    if (client != null) {
      if (!client.isConnected()) {
        throw new FTPException("Client not connected");
      }
      boolean logoutSuccess = client.logout();
      client.disconnect();
      if (!logoutSuccess) {
        LOG.warn("Logout failed while disconnecting, error code - "
            + client.getReplyCode());
      }
    }
  }
259445
async def disconnect_message(self, message, context):
        

        conn_string = message.get('connection_string')
        client_id = context.user_data

        await self.disconnect(client_id, conn_string)
1233781
public synchronized void close() throws IOException {
        if(getStatus().equals(ConnectionStatus.CLOSED)){
            return ;
        }
        if (LOGGER.isDebugEnabled()) {
            LOGGER.debug("Closing client for session: 0x"
                      + getSessionId());
        }
        connectRun.set(false);

        try{
            clientSocket.cleanup();
        }catch(Exception e){
            LOGGER.warn("Close the WSDirectorySocket get error.", e);
        }

        try {
            setStatus(ConnectionStatus.CLOSED);
            sendCloseSession();
            closeSession();
            eventThread.queueEventOfDeath();
        } catch (ServiceException e) {
            LOGGER.warn("Execute the CloseSession Protocol failed when close", e);
        }
    }
1210086
def disconnect(self, close=True):
        
        if not self._connected:
            # already disconnected so let's return
            return

        if close:
            for open in list(self.open_table.values()):
                open.close(False)

            for tree in list(self.tree_connect_table.values()):
                tree.disconnect()

        log.info("Session: %s - Logging off of SMB Session" % self.username)
        logoff = SMB2Logoff()
        log.info("Session: %s - Sending Logoff message" % self.username)
        log.debug(str(logoff))
        request = self.connection.send(logoff, sid=self.session_id)

        log.info("Session: %s - Receiving Logoff response" % self.username)
        res = self.connection.receive(request)
        res_logoff = SMB2Logoff()
        res_logoff.unpack(res['data'].get_value())
        log.debug(str(res_logoff))
        self._connected = False
        del self.connection.session_table[self.session_id]
871829
def delete_session(self, client_id):
        
        try:
            session = self._sessions[client_id][0]
        except KeyError:
            session = None
        if session is None:
            self.logger.debug("Delete session : session %s doesn't exist" % client_id)
            return

        # Delete subscriptions
        self.logger.debug("deleting session %s subscriptions" % repr(session))
        self._del_all_subscriptions(session)

        self.logger.debug("deleting existing session %s" % repr(self._sessions[client_id]))
        del self._sessions[client_id]
54695
def disconnect(self):
        
        if self.con is not None:
            self.con.close()
            log.debug('Closed connection with with set-top box at %s:%s.',
                      self.ip, self.port)
1185592
def close(self):
        
        # Disconnect with a fancy message, then close connection
        if self._connection is not None:
            self._connection.disconnect("Bot is quitting")
            self._connection.close()
            self._connection = None

        # Stop the client loop
        self.__stopped.set()

        if self.__thread is not None:
            try:
                self.__thread.join(5)
            except RuntimeError:
                pass
            self.__thread = None
606154
def remove_session_id(self, sid):
        
        for uid in self.get('sid2uid', sid):
            self.remove('uid2sid', uid, sid)
        self.delete('sid2uid', sid)

        for sub in self.get('sid2sub', sid):
            self.remove('sub2sid', sub, sid)
        self.delete('sid2sub', sid)
1373455
def auto_unsubscribe(self, sid, limit=1):
        
        if self.is_draining:
            raise ErrConnectionDraining
        yield self._unsubscribe(sid, limit)
585777
protected void disconnect() {
		if (channel != null) {
			try {
				channel.close();
			} catch (Throwable cause) {
				logger.warn("Unexpected error occurred while closing AMQP channel!", cause);
			} finally {
				channel = null;
			}
		}
		if (client != null) {
			try {
				client.close();
			} catch (Throwable cause) {
				logger.warn("Unexpected error occurred while closing AMQP client!", cause);
			} finally {
				client = null;
			}
		}
	}
309250
async def close(self):
        
        if self._closed:
            return

        await self.http.close()
        self._closed = True

        for voice in self.voice_clients:
            try:
                await voice.disconnect()
            except Exception:
                # if an error happens during disconnects, disregard it.
                pass

        if self.ws is not None and self.ws.open:
            await self.ws.close()

        self._ready.clear()
970613
def close(self):
        
        time_spent = time.time() - self.time_start
        logger.debug(
            '<{}> Disconnect from [{}]:{}, time spent {:.3f} seconds'.format(
                self.id, self.client_ip, self.client_port, time_spent))
        return Milter.CONTINUE
32437
def close(self, error=None):
        
        if self.state is ConnectionStates.DISCONNECTED:
            return
        with self._lock:
            if self.state is ConnectionStates.DISCONNECTED:
                return
            log.info('%s: Closing connection. %s', self, error or '')
            self._update_reconnect_backoff()
            self._sasl_auth_future = None
            self._protocol = KafkaProtocol(
                client_id=self.config['client_id'],
                api_version=self.config['api_version'])
            if error is None:
                error = Errors.Cancelled(str(self))
            ifrs = list(self.in_flight_requests.items())
            self.in_flight_requests.clear()
            self.state = ConnectionStates.DISCONNECTED
            # To avoid race conditions and/or deadlocks
            # keep a reference to the socket but leave it
            # open until after the state_change_callback
            # This should give clients a change to deregister
            # the socket fd from selectors cleanly.
            sock = self._sock
            self._sock = None

        # drop lock before state change callback and processing futures
        self.config['state_change_callback'](self.node_id, sock, self)
        sock.close()
        for (_correlation_id, (future, _timestamp)) in ifrs:
            future.failure(error)