Created
March 21, 2013 16:31
-
-
Save Gowiem/5214440 to your computer and use it in GitHub Desktop.
Initializing WebSocket Manager
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
def initialize | |
puts "--Initializing Message Monitor" | |
EM.run { | |
puts "before Faye::Websocket::Client.new()" | |
ws = Faye::WebSocket::Client.new("wss://somewebsocket.com:/ms/monitor") | |
puts "After Faye::Websocket::Client.new()" | |
ws.onopen do |event| | |
puts "WebSocket Opened!" | |
ws.send('Hello, world!') | |
end | |
ws.onmessage do |event| | |
puts "WebSocket Message:" | |
message = JSON.parse(event.date) | |
puts message | |
end | |
ws.onclose do |event| | |
code = JSON.parse(event.code) | |
reason = JSON.parse(event.reason) | |
puts "MessageMonitor onClose:" | |
puts "Code: #{code}" | |
puts "Reason: #{reason}" | |
ws = nil | |
end | |
} | |
puts "Before end of MessageMonitor Initialize" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment