Call this method when a client disconnected.
329660
def disconnected(self, client):
        """"""
        if client not in self.clients:
            # already disconnected.
            return
        self.clients.remove(client)
        self._log_disconnected(client)
        self._close(client)
578070
def disconnect(self):
        
        self.connState = Client.DISCONNECTED
        if self.conn is not None:
            self._logger.info('Disconnecting')
            self.conn.disconnect()
            self.wrapper.connectionClosed()
            self.reset()
101957
def my_on_connect(client):
    
    client.send('You connected from %s\n' % client.addrport())
    if CLIENTS:
        client.send('Also connected are:\n')
        for neighbor in CLIENTS:
            client.send('%s\n' % neighbor.addrport())
    else:
        client.send('Sadly, you are alone.\n')
    CLIENTS.append(client)
221256
def on_disconnect(self=None) -> callable:
        

        def decorator(func: callable) -> Handler:
            handler = pyrogram.DisconnectHandler(func)

            if self is not None:
                self.add_handler(handler)

            return handler

        return decorator
365883
private synchronized void notifyConnectionLost(final IoSession session) {
        new Thread("Connection-Closed-Notifier") {
            @Override
            public void run() {
                // todo: sml: should consider rationalising these so they're all HandlerListeners..
                if (connectedObjectManager != null) {
                    connectedObjectManager.sessionTerminated(session);
                }
                for (HandlerListener listener : handlerListeners) {
                    listener.sessionClosed(session);
                }
                RequestResponseManager requestResponseManager = (RequestResponseManager) session.getAttribute(RequestResponseManager.SESSION_KEY);
                if (requestResponseManager != null) {
                    requestResponseManager.sessionClosed(session);
                }
            }
        }.start();
    }
467879
def disconnect(self, *args, **kwargs):
        """"""
        self.logged_on = False
        CMClient.disconnect(self, *args, **kwargs)
1183686
def client_disconnect(self, event):
        
        self.log("Removing disconnected client from subscriptions", lvl=debug)
        client_uuid = event.clientuuid
        self._unsubscribe(client_uuid)
646843
function onDISCONNECT(self, reason, code, desc, lang) { // Client/Server
  if (code !== DISCONNECT_REASON.BY_APPLICATION) {
    var err = new Error(desc || reason);
    err.code = code;
    self.emit('error', err);
  }
  self.reset();
}
1147655
def _logoutclient(self, useruuid, clientuuid):
        """"""

        self.log("Cleaning up client of logged in user.", lvl=debug)
        try:
            self._users[useruuid].clients.remove(clientuuid)
            if len(self._users[useruuid].clients) == 0:
                self.log("Last client of user disconnected.", lvl=verbose)

                self.fireEvent(userlogout(useruuid, clientuuid))
                del self._users[useruuid]

            self._clients[clientuuid].useruuid = None
        except Exception as e:
            self.log("Error during client logout: ", e, type(e),
                     clientuuid, useruuid, lvl=error,
                     exc=True)
275153
def clientdisconnect(self, event):
        

        try:
            if event.clientuuid == self.remote_controller:
                self.log("Remote controller disconnected!", lvl=critical)
                self.remote_controller = None
        except Exception as e:
            self.log("Strange thing while client disconnected", e, type(e))
208916
def on_disconnect(self):
        ""
        if self._sock is not None:
            self._sock.close()
            self._sock = None
        if self._buffer is not None:
            self._buffer.close()
            self._buffer = None
        self.encoding = None
1277577
def _on_client_connect(self, data):
        """"""
        client = None
        if data.get('id') in self._clients:
            client = self._clients[data.get('id')]
            client.update_connected(True)
        else:
            client = Snapclient(self, data.get('client'))
            self._clients[data.get('id')] = client
            if self._new_client_callback_func and callable(self._new_client_callback_func):
                self._new_client_callback_func(client)
        _LOGGER.info('client %s connected', client.friendly_name)
1071325
def _on_disconnect(self, result):
        

        success, _, context = self._parse_return(result)

        callback = context['callback']
        connection_id = context['connection_id']
        handle = context['handle']

        callback(connection_id, self.id, success, "No reason given")
        self._remove_connection(handle)
501905
def on_disconnected(self):
        

        with self._handover_cond:

            # Wait until receiver has processed the previous notification
            while len(self._handover_dict) > 0:
                self._handover_cond.wait(self._wait_timeout)

            # Indicate to receiver that there is a termination notification
            self._handover_dict['headers'] = None  # terminate receiver
            self._handover_dict['message'] = None
            self._handover_cond.notifyAll()
276891
def disconnect(self):
        """"""

        if not self.connected:
            raise HardwareError("Cannot disconnect when we are not connected")

        # Close the streaming and tracing interfaces when we disconnect
        self._reports = None
        self._traces = None

        self._loop.run_coroutine(self.adapter.disconnect(0))
        self.connected = False
        self.connection_interrupted = False
        self.connection_string = None
242782
function(callback){
        callback = callback || noop;

        if(!this._client){
            return callback();
        }
        this._client.shutdown(function(err){
            if(!this._define_connection){
                return callback(err);
            }
            this._define_connection.shutdown(function(derr){
                callback(err || derr);
            });
        }.bind(this));
    }
404491
def disconnect(self, func=None):
        """"""
        if func is None:
            self._connections = []
        else:
            self._connections.remove(func)