Sha256: 8f68236a297603d53109cc07d23efa9a852de7138adbb252830c734ad117f459
Contents?: true
Size: 869 Bytes
Versions: 1
Compression:
Stored size: 869 Bytes
Contents
# # frozen_string_literal: true require 'faye/websocket' require 'eventmachine' require 'json' require 'io/console' module MKIt class LogWebSocketClient def initialize(uri, options) @uri = uri @options = options trap("SIGINT") do puts "Bye..." EventMachine.stop end end def doIt EM.run { ws = Faye::WebSocket::Client.new(@uri, nil, @options) ws.on :open do |_event| puts "Connected to WebSocket server" puts "\r\n" end ws.on :message do |event| puts event.data end ws.on :error do |event| p [:error, event.message] ws = nil EventMachine.stop end ws.on :close do |_event| ws = nil puts "\r\n" EventMachine.stop end } end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
mkit-0.8.0 | lib/mkit/client/log_websocket_client.rb |