Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
constructor (backendVM, opts={}) {
// setup the WebSocket server
this.backendVM = backendVM
this.server = new WebSocketServer({
port: opts.port || DEFAULT_PORT
})
this.isReadyPromise = new Promise((resolve, reject) => {
this.server.on('listening', resolve)
this.server.on('error', reject)
})
// establish the method handlers
this.registerCommands()
this.callQueue = [] // backlog of RPC requests
this.activeCall = null // call currently being processed
}
listenWs: ({ host, port }) => {
const wsServer = new WsJsonRpcServer({
port: port || 8646,
host: host || 'localhost',
});
// register an RPC method
Object.keys(nodeApi).forEach(key => {
wsServer.register(key.toString(), withParams(nodeApi[key]));
});
return new Promise(resolve => {
wsServer.on('listening', () => {
return resolve({
address: wsServer.wss.options.host,
port: wsServer.wss.options.port,
});
});
constructor() {
this.registered = {};
this.port = port;
this.host = host;
this.path = `/v${version}`;
this.webSocketServer = new WebSocketServer({
port: this.port,
host: this.host,
});
}
initServer(host?: string, port?: number) {
host = host ? host : this.host;
port = port ? port : this.port;
this.rpcNode = new WebSocketServer({
port: port,
host: host
});
}