Handle a client parting from channel(s).
177724
def handle_part(self, params):
        
        for pchannel in params.split(','):
            if pchannel.strip() in self.server.channels:
                # Send message to all clients in all channels user is in, and
                # remove the user from the channels.
                channel = self.server.channels.get(pchannel.strip())
                response = ':%s PART :%s' % (self.client_ident(), pchannel)
                if channel:
                    for client in channel.clients:
                        client.send_queue.append(response)
                channel.clients.remove(self)
                self.channels.pop(pchannel)
            else:
                _vars = self.server.servername, pchannel, pchannel
                response = ':%s 403 %s :%s' % _vars
                self.send_queue.append(response)
343548
def handle_stream(self, stream, address):
        '''
        
        '''
        log.trace('Req client %s connected', address)
        self.clients.append((stream, address))
        unpacker = msgpack.Unpacker()
        try:
            while True:
                wire_bytes = yield stream.read_bytes(4096, partial=True)
                unpacker.feed(wire_bytes)
                for framed_msg in unpacker:
                    if six.PY3:
                        framed_msg = salt.transport.frame.decode_embedded_strs(
                            framed_msg
                        )
                    header = framed_msg['head']
                    self.io_loop.spawn_callback(self.message_handler, stream, header, framed_msg['body'])

        except StreamClosedError:
            log.trace('req client disconnected %s', address)
            self.clients.remove((stream, address))
        except Exception as e:
            log.trace('other master-side exception: %s', e)
            self.clients.remove((stream, address))
            stream.close()
546012
def call_closers(self, client, clients_list):
        
        for func in self.closers:
            func(client, clients_list)
815381
def part(self, channel, reason=''):
        
        with self.lock:
            self.is_in_channel(channel)

            self.send('PART %s :%s' % (channel, reason))
            msg = self._recv(expected_replies=('PART',))
            if msg[0] == 'PART':
                del self.channels[msg[1]]
                if not self.hide_called_events:
                    self.stepback()
1324890
def on_close(self):
        
        print 'Connection closed.'
        self.remove_client()
        
        client_count = len(self.get_clients().keys())
        new_client_message = '1 client disconnected, now we have %d %s!' % (client_count, 'client' if client_count <= 1 else 'clients')
        self.broadcast(new_client_message)
892523
def disconnect(self, func):
        """"""
        if id(self) not in _alleged_receivers:
            return
        l = _alleged_receivers[id(self)]
        try:
            l.remove(func)
        except ValueError:
            return
        if not l:
            del _alleged_receivers[id(self)]
1332489
def close(self):
        
        if not self.active:
            return
        self.active = False
        self.packetizer.close()
        self.join()
        for chan in self._channels.values():
            chan._unlink()
200594
function exit() {
  if (!initialized || exited)
    return;

  log('Exiting...', true);

  // Leave the twitch channel
  if (ircClient)
    ircClient.part(config.channel);

  // Leave discord
  if (discordClient)
    discordClient.disconnect();

  // Clear the stream check interval
  if (streamInterval)
    clearInterval(streamInterval);

  // Clear all the timeouts
  timeouts.forEach(function(t) {
    clearTimeout(t);
  });

  exited = true;
}
165356
def _do_close(self):
        
        AMQP_LOGGER.debug('Closed channel #%d' % self.channel_id)
        self.is_open = False
        del self.connection.channels[self.channel_id]
        self.channel_id = self.connection = None
        self.callbacks = {}
40303
def endSubscription(self, subscriber):
        
        self._reqId2Contract.pop(subscriber.reqId, None)
        self.reqId2Subscriber.pop(subscriber.reqId, None)
1252347
def on_disconnect(client):
    
    print "-- Lost connection to %s" % client.addrport()
    CLIENT_LIST.remove(client)
    broadcast('%s leaves the conversation.\n' % client.addrport() )
1342206
def exit(self):
        """"""
        if self.client is not None:
            self.client.close()
        if self.context is not None:
            self.context.destroy()
159564
def end(self):
        """"""
        if not self.args.disable_autodiscover:
            self.autodiscover_client.close()
        self.server.end()
1367532
def unsubscribe(self, client):
        """"""
        for channel in self.channels.values():
            channel.unsubscribe(client)
1356769
def handle_ChannelCloseOK(self, frame):
        
        assert self.channel._closing, "received a not expected CloseOk"
        # Release the `close` method's future
        self.synchroniser.notify(spec.ChannelCloseOK)

        exc = ChannelClosed()
        self._close_all(exc)
209389
private void maybeTerminateChannel() {
    if (terminated) {
      return;
    }
    if (shutdown.get() && subchannels.isEmpty() && oobChannels.isEmpty()) {
      channelLogger.log(ChannelLogLevel.INFO, "Terminated");
      channelz.removeRootChannel(this);
      terminated = true;
      terminatedLatch.countDown();
      executorPool.returnObject(executor);
      balancerRpcExecutorHolder.release();
      // Release the transport factory so that it can deallocate any resources.
      transportFactory.close();
    }
  }
549164
def exit(self):
        """"""
        # To ensure all connections are properly closed
        self.client.flush()
        self.client.close()
        # Call the father method
        super(Export, self).exit()