Created
January 11, 2017 05:17
-
-
Save arturodz/6171c4cc0492f6f5c480c2273f74ebd6 to your computer and use it in GitHub Desktop.
This file contains 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
EM.run { | |
ws = Faye::WebSocket::Client.new('wss://ws.localhost.com') | |
ws.on :open do |event| | |
puts [:open] | |
ws.send("Alo!") | |
end | |
ws.on :error do| event| | |
puts "Error: #{event.data}" | |
end | |
ws.on :message do |event| | |
puts [:message, event.data] | |
if event.data.something = true | |
# execute code here | |
end | |
end | |
ws.on :close do |event| | |
puts "Client disconnected with status code: #{event.code} and reason: #{event.reason}" | |
exit 1 | |
end | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment