Class: Bixby::WebSocket::Client
- Inherits:
-
Object
- Object
- Bixby::WebSocket::Client
- Includes:
- Log
- Defined in:
- lib/bixby-common/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
Methods included from Log
Constructor Details
#initialize(url, handler) ⇒ Client
Returns a new instance of Client.
15 16 17 18 19 20 |
# File 'lib/bixby-common/websocket/client.rb', line 15 def initialize(url, handler) @url = url @handler = handler @tries = 0 @exiting = false end |
Instance Attribute Details
#api ⇒ Object (readonly)
Returns the value of attribute api.
13 14 15 |
# File 'lib/bixby-common/websocket/client.rb', line 13 def api @api end |
#ws ⇒ Object (readonly)
Returns the value of attribute ws.
13 14 15 |
# File 'lib/bixby-common/websocket/client.rb', line 13 def ws @ws end |
Instance Method Details
#start ⇒ Object
Start the Client thread
NOTE: This call never returns!
25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/bixby-common/websocket/client.rb', line 25 def start @exiting = false Kernel.trap("EXIT") do @exiting = true end EM.run { connect() } end |
#stop ⇒ Object
38 39 40 41 |
# File 'lib/bixby-common/websocket/client.rb', line 38 def stop @exiting = true EM.stop_event_loop end |