TinyBase logoTinyBase β

getWebSocketServer

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

getWebSocketServer(): WebSocketServer
returnsWebSocketServer

The WebSocketServer reference.

Example

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

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

const webSocketServer = new WebSocketServer({port: 8047});
const server = createWsServer(webSocketServer);

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

server.destroy();

Since

v5.0.0