Class: Bixby::WebSocket::Client
- Inherits:
-
Object
- Object
- Bixby::WebSocket::Client
- Includes:
- Log
- Defined in:
- lib/bixby-agent/websocket/client.rb
Overview
WebSocket Client
Instance Attribute Summary collapse
-
#api ⇒ Object
readonly
Returns the value of attribute api.
-
#ws ⇒ Object
readonly
Returns the value of attribute ws.
Instance Method Summary collapse
-
#initialize(url, handler) ⇒ Client
constructor
A new instance of Client.
-
#start ⇒ Object
Start the Client thread.
- #stop ⇒ Object
Constructor Details
#initialize(url, handler) ⇒ Client
Returns a new instance of Client.
18 19 20 21 22 23 24 |
# File 'lib/bixby-agent/websocket/client.rb', line 18 def initialize(url, handler) @url = url @handler = handler @tries = 0 @exiting = false @thread_pool = Bixby::ThreadPool.new(:min_size => 1, :max_size => 4) end |
Instance Attribute Details
#api ⇒ Object (readonly)
Returns the value of attribute api.
16 17 18 |
# File 'lib/bixby-agent/websocket/client.rb', line 16 def api @api end |
#ws ⇒ Object (readonly)
Returns the value of attribute ws.
16 17 18 |
# File 'lib/bixby-agent/websocket/client.rb', line 16 def ws @ws end |
Instance Method Details
#start ⇒ Object
Start the Client thread
NOTE: This call never returns!
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/bixby-agent/websocket/client.rb', line 29 def start @exiting = false Kernel.trap("EXIT") do # :nocov: @exiting = true # :nocov: end logger.debug "connecting to #{@url}" EM.run { connect() } end |
#stop ⇒ Object
45 46 47 48 |
# File 'lib/bixby-agent/websocket/client.rb', line 45 def stop @exiting = true EM.stop_event_loop if EM.reactor_running? end |