Disconnect a client. :param sid: Session ID of the client. :param namespace: The Socket.IO namespace to disconnect. If this argument is omitted the default namespace is used. :param ignore_queue: Only used when a message queue is configured. If
(self, sid, namespace=None, ignore_queue=False)
| 406 | return _session_context_manager(self, sid, namespace) |
| 407 | |
| 408 | async def disconnect(self, sid, namespace=None, ignore_queue=False): |
| 409 | """Disconnect a client. |
| 410 | |
| 411 | :param sid: Session ID of the client. |
| 412 | :param namespace: The Socket.IO namespace to disconnect. If this |
| 413 | argument is omitted the default namespace is used. |
| 414 | :param ignore_queue: Only used when a message queue is configured. If |
| 415 | set to ``True``, the disconnect is processed |
| 416 | locally, without broadcasting on the queue. It is |
| 417 | recommended to always leave this parameter with |
| 418 | its default value of ``False``. |
| 419 | |
| 420 | Note: this method is a coroutine. |
| 421 | """ |
| 422 | namespace = namespace or '/' |
| 423 | if ignore_queue: |
| 424 | delete_it = self.manager.is_connected(sid, namespace) |
| 425 | else: |
| 426 | delete_it = await self.manager.can_disconnect(sid, namespace) |
| 427 | if delete_it: |
| 428 | self.logger.info('Disconnecting %s [%s]', sid, namespace) |
| 429 | eio_sid = self.manager.pre_disconnect(sid, namespace=namespace) |
| 430 | if eio_sid in self._binary_packet: |
| 431 | del self._binary_packet[eio_sid] |
| 432 | await self._send_packet(eio_sid, self.packet_class( |
| 433 | packet.DISCONNECT, namespace=namespace)) |
| 434 | await self._trigger_event('disconnect', namespace, sid, |
| 435 | self.reason.SERVER_DISCONNECT) |
| 436 | await self.manager.disconnect(sid, namespace=namespace, |
| 437 | ignore_queue=True) |
| 438 | |
| 439 | async def shutdown(self): |
| 440 | """Stop Socket.IO background tasks. |