destroy
The destroy
method provides a way to clean up the server at the end of its use.
destroy(): Promise<void>
returns | Promise<void> |
---|
This closes the underlying WebSocketServer that was provided when the WsServerSimple
was created. This method is asynchronous.
Example
This example creates a WsServerSimple
and then destroys it again, closing the underlying WebSocketServer.
import {createWsServerSimple} from 'tinybase/synchronizers/synchronizer-ws-server-simple';
import {WebSocketServer} from 'ws';
const webSocketServer = new WebSocketServer({port: 8053});
webSocketServer.on('close', () => {
console.log('WebSocketServer closed');
});
const server = createWsServerSimple(webSocketServer);
await server.destroy();
// ...
// -> 'WebSocketServer closed'
Since
v5.4.0