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

Difficult to have WSServer and Express on the same port #43

Closed
elgiano opened this issue May 14, 2020 · 2 comments
Closed

Difficult to have WSServer and Express on the same port #43

elgiano opened this issue May 14, 2020 · 2 comments

Comments

@elgiano
Copy link
Contributor

elgiano commented May 14, 2020

Hi, first of all thanks for this super useful package!
I'm making a web interface for supercollider, and I need WSServer and Express on the same port. I use Express to serve the interface (and adb to forward ports between my local machine and an android smartphone).

It would be nice to have the bridge plugin accept a server option, to be passed directly to WebSocketServer. This wouldn't disrupt other use-cases and it would make mine much cleaner :)

I could submit a Pull Request, for now I'm directly hacking into the osc-js.js :)

@adzialocha
Copy link
Owner

Hi @elgiano!

Thank you! Excuse my late reply, but in case you are still interested, could you share a snipped of how you currently pass on that server option to the WebSocketServer? Would love to see an API example.

@elgiano
Copy link
Contributor Author

elgiano commented Jan 15, 2021

Hi @adzialocha! Thanks for your reply.
Took me a while to dig it out from where it was, but this is what I was doing:
(in osc.js, open() method of BridgePlugin)

new WebSocketServer({
    server: options.wsServer.server,
    /*host: options.wsServer.host,
    port: options.wsServer.port*/
})

Instead of passing host and port, you can pass directly a server option. Here I made it a bit blunt, of course it should be made conditional :)
You'll find the server option listed down here: https://github.com/websockets/ws/blob/master/doc/ws.md#new-websocketserveroptions-callback

They also have an example

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants