Called by :class:`Broker` to force disconnect the stream. The base
        implementation simply closes :attr:`receive_side` and
        :attr:`transmit_side` and unregisters the stream from the broker.
764592
def on_disconnect(self, broker):
        
        LOG.debug('%r.on_disconnect()', self)
        if self.receive_side:
            broker.stop_receive(self)
            self.receive_side.close()
        if self.transmit_side:
            broker._stop_transmit(self)
            self.transmit_side.close()
        fire(self, 'disconnect')
175237
void close() {
        try {
            performTeardownExchange();
        } catch (IOException e) {
            logger.warn("Problem reporting our intention to close the dbserver connection", e);
        }
        try {
            channel.close();
        } catch (IOException e) {
            logger.warn("Problem closing dbserver client output channel", e);
        }
        try {
            os.close();
        } catch (IOException e) {
            logger.warn("Problem closing dbserver client output stream", e);
        }
        try {
            is.close();
        } catch (IOException e) {
            logger.warn("Problem closing dbserver client input stream", e);
        }
        try {
            socket.close();
        } catch (IOException e) {
            logger.warn("Problem closing dbserver client socket", e);
        }
    }
252442
def close_stream(self):
        """"""
        if not self.is_connected:
            return

        self.stream.close()
        self.state = DISCONNECTED
        self.on_close.send(self)
557012
private void close(T stream) {

        // Attempt to close stream
        try {
            stream.close();
        }
        catch (IOException e) {
            logger.warn("Unable to close intercepted stream: {}", e.getMessage());
            logger.debug("I/O error prevented closure of intercepted stream.", e);
        }

        // Notify waiting threads that the stream has ended
        synchronized (stream) {
            stream.notify();
        }

    }
440361
def on_receive(self, broker):
        
        buf = self.receive_side.read()
        if not buf:
            return self.on_disconnect(broker)

        self.buf += buf.decode('utf-8', 'replace')
        while u'\n' in self.buf:
            lines = self.buf.split('\n')
            self.buf = lines[-1]
            for line in lines[:-1]:
                LOG.debug('%s: %s', self.stream.name, line.rstrip())
464201
async def close(self):
        

        # Remove the core NATS Streaming subscriptions.
        await self._close()

        req = protocol.CloseRequest()
        req.clientID = self._client_id
        msg = await self._nc.request(
            self._close_req_subject,
            req.SerializeToString(),
            self._connect_timeout,
            )
        resp = protocol.CloseResponse()
        resp.ParseFromString(msg.data)

        if resp.error != "":
            raise StanError(resp.error)
102665
def on_disconnect(self):
        ""
        if self._stream is not None:
            self._stream = None
        if self._buffer is not None:
            self._buffer.close()
            self._buffer = None
        self.encoding = None
350245
def disconnect(self):
        
        self._parser.on_disconnect()
        if self._sock is None:
            return
        try:
            self._sock.shutdown(socket.SHUT_RDWR)
            self._sock.close()
        except socket.error:
            pass
        self._sock = None
395942
def disconnect(self):
        
        # Stop the timer
        self.__stop_timer()

        # Unlock all publishers
        for event in self.__in_flight.values():
            event.set()

        # Disconnect from the server
        self.__mqtt.disconnect()

        # Stop the MQTT loop thread
        # Use a thread to avoid a dead lock in Paho
        thread = threading.Thread(target=self.__mqtt.loop_stop)
        thread.daemon = True
        thread.start()

        # Give it some time
        thread.join(4)
1174146
def disconnect(self, cback, subscribers=None, instance=None):
        
        if subscribers is None:
            subscribers = self.subscribers
        # wrapper
        if self._fdisconnect is not None:
            def _disconnect(cback):
                self._disconnect(subscribers, cback)

            notify = partial(self._notify_one, instance)
            if instance is not None:
                result = self._fdisconnect(instance, cback, subscribers,
                                           _disconnect, notify)
            else:
                result = self._fdisconnect(cback, subscribers, _disconnect,
                                           notify)
            if inspect.isawaitable(result):
                result = pull_result(result)
        else:
            self._disconnect(subscribers, cback)
            result = None
        return result
696120
async def close(self):
        
        if self.__isClosed:
            return
        self.__isClosed = True
        self.__setSignalingState('closed')

        # stop senders / receivers
        for transceiver in self.__transceivers:
            await transceiver.stop()
        if self.__sctp:
            await self.__sctp.stop()

        # stop transports
        for transceiver in self.__transceivers:
            await transceiver._transport.stop()
            await transceiver._transport.transport.stop()
        if self.__sctp:
            await self.__sctp.transport.stop()
            await self.__sctp.transport.transport.stop()
        self.__updateIceConnectionState()

        # no more events will be emitted, so remove all event listeners
        # to facilitate garbage collection.
        self.remove_all_listeners()
1085
def _disconnect(self, exc_info=False):
        """"""
        if self._stream:
            self._stream.close(exc_info=exc_info)
1170643
protected void disconnect() {

		// Stop broadcaster
		if (locator != null) {
			locator.disconnect();
			locator = null;
		}

		// Stop gossiper's timer
		if (gossiperTimer != null) {
			gossiperTimer.cancel(false);
			gossiperTimer = null;
		}

		// Close socket reader
		if (reader != null) {
			reader.disconnect();
			reader = null;
		}

		// Close socket writer
		if (writer != null) {
			writer.disconnect();
			writer = null;
		}
	}
494490
def _data_channel_close(self, channel, transmit=True):
        
        if channel.readyState not in ['closing', 'closed']:
            channel._setReadyState('closing')
            self._reconfig_queue.append(channel.id)
            if len(self._reconfig_queue) == 1:
                asyncio.ensure_future(self._transmit_reconfig())
261690
def stop_receive(self, stream):
        
        _vv and IOLOG.debug('%r.stop_receive(%r)', self, stream)
        self.defer(self.poller.stop_receive, stream.receive_side.fd)
600221
def close(self):
        

        if self.stream is None:
            return

        try:
            self.stream.isatty()

            if self.stream.name in ["<stdin>", "<stdout>", "<stderr>"]:
                return
        except AttributeError:
            pass
        except ValueError:
            # raised when executing an operation to a closed stream
            pass

        try:
            from _pytest.compat import CaptureIO
            from _pytest.capture import EncodedFile

            if isinstance(self.stream, (CaptureIO, EncodedFile)):
                # avoid closing streams for pytest
                return
        except ImportError:
            pass

        try:
            from ipykernel.iostream import OutStream

            if isinstance(self.stream, OutStream):
                # avoid closing streams for Jupyter Notebook
                return
        except ImportError:
            pass

        try:
            self.stream.close()
        except AttributeError:
            self._logger.logger.warn(
                "the stream has no close method implementation: type={}".format(type(self.stream))
            )
        finally:
            self._stream = None
1292396
async def disconnect(self, abort=False):
        
        if self.state == 'connected':
            await self._send_packet(packet.Packet(packet.CLOSE))
            await self.queue.put(None)
            self.state = 'disconnecting'
            await self._trigger_event('disconnect', run_async=False)
            if self.current_transport == 'websocket':
                await self.ws.close()
            if not abort:
                await self.read_loop_task
            self.state = 'disconnected'
            try:
                client.connected_clients.remove(self)
            except ValueError:  # pragma: no cover
                pass
        self._reset()