Class: SchwabRb::Stream::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/schwab_rb/stream/client.rb

Instance Method Summary collapse

Constructor Details

#initialize(client) ⇒ Client

Returns a new instance of Client.



9
10
11
12
# File 'lib/schwab_rb/stream/client.rb', line 9

def initialize(client)
  @stream = Base.new(client)
  @thread = nil
end

Instance Method Details

#connected?Boolean

Returns:

  • (Boolean)


39
40
41
# File 'lib/schwab_rb/stream/client.rb', line 39

def connected?
  @stream.connected?
end

#on(service_symbol, symbols: nil, fields: nil, &block) ⇒ Object



14
15
16
17
# File 'lib/schwab_rb/stream/client.rb', line 14

def on(service_symbol, symbols: nil, fields: nil, &block)
  @stream.on(service_symbol, symbols: symbols, fields: fields, &block)
  self
end

#startObject



19
20
21
22
23
24
# File 'lib/schwab_rb/stream/client.rb', line 19

def start
  @thread = Thread.new do
    @stream.start
  end
  @thread.join
end

#start_asyncObject



26
27
28
29
30
31
# File 'lib/schwab_rb/stream/client.rb', line 26

def start_async
  @thread = Thread.new do
    @stream.start
  end
  self
end

#stopObject



33
34
35
36
37
# File 'lib/schwab_rb/stream/client.rb', line 33

def stop
  @stream.stop
  @thread&.join(5)
  @thread = nil
end