Class: Binance::WebSocketBase
- Inherits:
-
Object
- Object
- Binance::WebSocketBase
- Defined in:
- lib/binance/websocket_base.rb
Overview
Base Websocket
Direct Known Subclasses
Instance Method Summary collapse
- #create_connection(url, cbs) ⇒ Object
-
#initialize(options = {}) ⇒ WebSocketBase
constructor
A new instance of WebSocketBase.
- #subscribe_to(url, cbs) ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ WebSocketBase
Returns a new instance of WebSocketBase.
9 10 11 12 13 |
# File 'lib/binance/websocket_base.rb', line 9 def initialize( = {}) @logger = [:logger] || Logger.new($stdout) @base_url = [:base_url] @ws_connection = nil end |
Instance Method Details
#create_connection(url, cbs) ⇒ Object
15 16 17 18 |
# File 'lib/binance/websocket_base.rb', line 15 def create_connection(url, cbs) @ws_connection = ::WebSocket::EventMachine::Client.connect(uri: url) add_callbacks(cbs) end |
#subscribe_to(url, cbs) ⇒ Object
20 21 22 |
# File 'lib/binance/websocket_base.rb', line 20 def subscribe_to(url, cbs) create_connection(url, cbs) end |