Last active
August 29, 2015 14:05
-
-
Save albanpeignier/eab36fe2ed0a15c52c84 to your computer and use it in GitHub Desktop.
Client Metalive pour déclencer une action
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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