Class: MKIt::LogWebSocketClient
- Inherits:
-
Object
- Object
- MKIt::LogWebSocketClient
- Defined in:
- lib/mkit/client/log_websocket_client.rb
Instance Method Summary collapse
- #doIt ⇒ Object
-
#initialize(uri, options) ⇒ LogWebSocketClient
constructor
A new instance of LogWebSocketClient.
Constructor Details
#initialize(uri, options) ⇒ LogWebSocketClient
Returns a new instance of LogWebSocketClient.
10 11 12 13 14 15 16 17 |
# File 'lib/mkit/client/log_websocket_client.rb', line 10 def initialize(uri, ) @uri = uri @options = trap("SIGINT") do puts "Bye..." EventMachine.stop end end |
Instance Method Details
#doIt ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/mkit/client/log_websocket_client.rb', line 19 def doIt EM.run { ws = Faye::WebSocket::Client.new(@uri, nil, @options) ws.on :open do |_event| puts "Connected to remote server" puts "\r\n" end ws.on :message do |event| puts event.data end ws.on :error do |event| p [:error, event.] ws = nil EventMachine.stop end ws.on :close do |_event| ws = nil puts "\r\n" EventMachine.stop end } end |