TinyBase logoTinyBase β

getWebSocketServer

The getWebSocketServer method returns a reference to the WebSocketServer being used for this WsServerSimple.

getWebSocketServer(): WebSocketServer
returnsWebSocketServer

The WebSocketServer reference.

Example

This example creates a WsServerSimple and then gets the WebSocketServer reference back out again.

import {WebSocketServer} from 'ws';
import {createWsServerSimple} from 'tinybase/synchronizers/synchronizer-ws-server-simple';

const webSocketServer = new WebSocketServer({port: 8053});
const server = createWsServerSimple(webSocketServer);

console.log(server.getWebSocketServer() == webSocketServer);
// -> true

server.destroy();

Since

v5.4.0