Skip to content

Instantly share code, notes, and snippets.

@albanpeignier
Last active August 29, 2015 14:05
Show Gist options
  • Save albanpeignier/eab36fe2ed0a15c52c84 to your computer and use it in GitHub Desktop.
Save albanpeignier/eab36fe2ed0a15c52c84 to your computer and use it in GitHub Desktop.
Client Metalive pour déclencer une action
require 'eventmachine'
require 'em-websocket-client'
require 'json'
EM.run do
conn = EventMachine::WebSocketClient.connect("ws://metalive.tryphon.eu:8080/api/streams/test/events.ws")
conn.errback do |e|
puts "Got error: #{e}"
end
conn.stream do |msg|
event = JSON.parse(msg)
if event["description"]["live"]
system "rmlsend ..."
end
end
conn.disconnect do
puts "gone"
EM::stop_event_loop
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment