[Screeninvader] [Janosh]built-in websocket support

Amir Hassan amir at viel-zu.org
Wed Mar 18 14:33:43 CET 2015


Janosh now supports websockets :D.

example:

<code>
#!/usr/local/bin/janosh -f

-- runs when /val is changed
function hello(key,value)
   Janosh:wsBroadcast(key) -- notify all clients of the value change
end

-- runs when a websocket message is received
function echo(handle, message)
   Janosh:wsSend(handle, message) -- echo message back
end

Janosh:wsOpen(9998) -- open websocket
Janosh:wsOnReceive(echo); -- install receive callback
Janosh:subscribe("/val", hello) -- install subscription callback

while true do
   janosh_sleep(1000) -- do something
end
</code>



More information about the Screeninvader mailing list