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

add web-socket support for gl_server? #20

Open
supsup opened this issue Aug 28, 2014 · 2 comments
Open

add web-socket support for gl_server? #20

supsup opened this issue Aug 28, 2014 · 2 comments

Comments

@supsup
Copy link

supsup commented Aug 28, 2014

Is this possible?
It would make debugging/making front end webpage stuff a lot easier.

@hobzcalvin
Copy link
Contributor

hobzcalvin commented May 20, 2016

Agreed! I'm trying this now...I'm getting "Client connected" from the gl_server, so that part works. Upon further investigation I see that the sockets used by gl_server may see the initial handshake, but won't be able to do the special websockets stuff without a supporting library.

Javascript:

var ws = new WebSocket("ws://localhost:7890");
ws.onopen = function () {
  var packet = new Uint8Array([ 0,0,0,9, 255,0,0, 0,255,0, 0,0,255 ]);
  ws.send(packet.buffer);
};

@hobzcalvin
Copy link
Contributor

Actually, I got this working with the help of websockify! It does exactly what's missing: acts as a websocket server for the browser, but sends the traffic to the standard socket the gl_server expects.
/path/to/websockify> ./websockify.py 7890 localhost:7891
/path/to/openpixelcontrol> bin/gl_server -l layouts/mylayout.json -p 7891

Two gotchas:

  • websockify needs the second arg of the WebSocket() constructor to be ['binary', 'base64']. Fine for gl_server, but fadecandy's server (which I'm using in "production") can only handle ['fcserver'].
  • Also fadecandy-only: OPC needs the 3rd and 4th bytes to define packet length, but fadecandy doesn't think that's necessary so it outputs a NOTICE to the log when they're non-zero. Appears to work fine, though.

cc @scanlime

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

No branches or pull requests

2 participants