Class: Cucumber::Pro::WebSocket::Session
- Inherits:
-
Object
- Object
- Cucumber::Pro::WebSocket::Session
- Defined in:
- lib/cucumber/pro/web_socket/session.rb
Instance Method Summary collapse
- #close ⇒ Object
- #error(exception) ⇒ Object
-
#initialize(url, logger, options) ⇒ Session
constructor
A new instance of Session.
- #send_message(message) ⇒ Object
Constructor Details
#initialize(url, logger, options) ⇒ Session
Returns a new instance of Session.
19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/cucumber/pro/web_socket/session.rb', line 19 def initialize(url, logger, ) @url, @logger = url, logger create_socket = -> worker { ws = Faye::WebSocket::Client.new(@url, nil, ping: 15) ws.on :open, &worker.method(:on_open) ws.on :error, &worker.method(:on_error) ws.on :message, &worker.method(:on_message) ws.on :close, &worker.method(:on_close) ws } @queue = Queue.new @socket = Worker.new(create_socket, logger, self, ) end |
Instance Method Details
#close ⇒ Object
39 40 41 42 43 44 |
# File 'lib/cucumber/pro/web_socket/session.rb', line 39 def close logger.debug [:session, :close] socket.close loop until socket.closed? self end |
#error(exception) ⇒ Object
46 47 48 49 50 51 |
# File 'lib/cucumber/pro/web_socket/session.rb', line 46 def error(exception) logger.fatal exception $stderr.puts "Cucumber Pro failed to send results: #{exception}" $stderr.puts exception.backtrace.join("\n") self end |
#send_message(message) ⇒ Object
33 34 35 36 37 |
# File 'lib/cucumber/pro/web_socket/session.rb', line 33 def () logger.debug [:session, :send, ] socket.send(.to_json) self end |