Class: Binance::WebSocketBase

Inherits:
Object
  • Object
show all
Defined in:
lib/binance/websocket_base.rb

Overview

Base Websocket

Direct Known Subclasses

Spot::WebSocket

Instance Method Summary collapse

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(options = {})
  @logger = options[:logger] || Logger.new($stdout)
  @base_url = options[: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