* Disconnects the socket manually. In that case, the socket will not try to reconnect. * * If this is the last active Socket instance of the {@link Manager}, the low-level connection will be closed. * * @example * const socket = io(); * * socket.on("disconnect", (reason) => {
()
| 897 | * @return self |
| 898 | */ |
| 899 | public disconnect(): this { |
| 900 | if (this.connected) { |
| 901 | debug(class="st">"performing disconnect (%s)", this.nsp); |
| 902 | this.packet({ type: PacketType.DISCONNECT }); |
| 903 | } |
| 904 | |
| 905 | class="cm">// remove socket from pool |
| 906 | this.destroy(); |
| 907 | |
| 908 | if (this.connected) { |
| 909 | class="cm">// fire events |
| 910 | this.onclose(class="st">"io client disconnect"); |
| 911 | } |
| 912 | return this; |
| 913 | } |
| 914 | |
| 915 | /** |
| 916 | * Alias for {@link disconnect()}. |
no test coverage detected