zestyping / openpixelcontrol

A simple stream protocol for controlling arrays of RGB lights.
http://openpixelcontrol.org/
353 stars 103 forks source link

add web-socket support for gl_server? #20

Open supsup opened 10 years ago

supsup commented 10 years ago

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

hobzcalvin commented 8 years ago

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 commented 8 years ago

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:

cc @scanlime