Skip to content

Refactor out WebsSocketManager from WebSockerServer#963

Merged
texodus merged 2 commits intomasterfrom
websocket-manager
Mar 9, 2020
Merged

Refactor out WebsSocketManager from WebSockerServer#963
texodus merged 2 commits intomasterfrom
websocket-manager

Conversation

@zemeolotu
Copy link
Contributor

This PR refactors out and exports a new standalone WebSocketManager class from WebSocketServer.

This refactor allows perspective to be remotely hosted in node servers other than WebSocketServer. WebsocketManager will manage all websocket connections and messages from a perspective websocket client.

As an example, here's how you'd use it in an express server

const app = require('express')();
const expressWs = require('express-ws')(app);

const manager = new WebSocketManager()
manager.host_table(name, table)

app.ws('/perspective/subscribe', ws =>  manager.add_connection(ws));

This PR also adds a node.js express server example hosting a perspective table

@timkpaine timkpaine added enhancement Feature requests or improvements JS labels Mar 7, 2020
Copy link
Member

@texodus texodus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! Thanks for the PR!

Appreciate the examples cleanup, in particular.

@texodus texodus merged commit 409e068 into master Mar 9, 2020
@texodus texodus deleted the websocket-manager branch March 9, 2020 19:48
@texodus texodus added internal Internal refactoring and code quality improvement and removed enhancement Feature requests or improvements labels Mar 31, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

internal Internal refactoring and code quality improvement JS

Development

Successfully merging this pull request may close these issues.

4 participants