Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor out WebsSocketManager from WebSockerServer #963

Merged
merged 2 commits into from
Mar 9, 2020

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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants