* Closes server connection * * @param [fn] optional, called as `fn([err])` on error OR all conns closed
(fn?: (err?: Error) => void)
| 742 | * @param [fn] optional, called as `fn([err])` on error OR all conns closed |
| 743 | */ |
| 744 | public close(fn?: (err?: Error) => void): void { |
| 745 | this._nsps.forEach((nsp) => { |
| 746 | nsp.sockets.forEach((socket) => { |
| 747 | socket._onclose("server shutting down"); |
| 748 | }); |
| 749 | |
| 750 | nsp.adapter.close(); |
| 751 | }); |
| 752 | |
| 753 | this.engine.close(); |
| 754 | |
| 755 | // restore the Adapter prototype, when the Socket.IO server was attached to a uWebSockets.js server |
| 756 | restoreAdapter(); |
| 757 | |
| 758 | if (this.httpServer) { |
| 759 | this.httpServer.close(fn); |
| 760 | } else { |
| 761 | fn && fn(); |
| 762 | } |
| 763 | } |
| 764 | |
| 765 | /** |
| 766 | * Registers a middleware, which is a function that gets executed for every incoming {@link Socket}. |
no test coverage detected