Module: Em::Nordnet::Feed::Connection
- Defined in:
- lib/em-nordnet/feed/connection.rb
Instance Attribute Summary collapse
-
#callbacks ⇒ Object
readonly
Returns the value of attribute callbacks.
-
#session ⇒ Object
readonly
Returns the value of attribute session.
Instance Method Summary collapse
- #connection_completed ⇒ Object
- #initialize(session) ⇒ Object
- #on_tick(&block) ⇒ Object
- #receive_data(json) ⇒ Object
- #send_data(data) ⇒ Object
- #ssl_handshake_completed ⇒ Object
- #subscribe(args) ⇒ Object
- #unbind ⇒ Object
Instance Attribute Details
#callbacks ⇒ Object (readonly)
Returns the value of attribute callbacks.
5 6 7 |
# File 'lib/em-nordnet/feed/connection.rb', line 5 def callbacks @callbacks end |
#session ⇒ Object (readonly)
Returns the value of attribute session.
5 6 7 |
# File 'lib/em-nordnet/feed/connection.rb', line 5 def session @session end |
Instance Method Details
#connection_completed ⇒ Object
20 21 22 |
# File 'lib/em-nordnet/feed/connection.rb', line 20 def connection_completed start_tls end |
#initialize(session) ⇒ Object
7 8 9 10 |
# File 'lib/em-nordnet/feed/connection.rb', line 7 def initialize(session) @session = session @callbacks = [] end |
#on_tick(&block) ⇒ Object
12 13 14 |
# File 'lib/em-nordnet/feed/connection.rb', line 12 def on_tick &block @callbacks << block end |
#receive_data(json) ⇒ Object
29 30 31 |
# File 'lib/em-nordnet/feed/connection.rb', line 29 def receive_data json callbacks.each { |callback| callback.call parse(json) } end |
#send_data(data) ⇒ Object
37 38 39 |
# File 'lib/em-nordnet/feed/connection.rb', line 37 def send_data data super "%s\n" % data # All writes must end with linefeed end |
#ssl_handshake_completed ⇒ Object
24 25 26 27 |
# File 'lib/em-nordnet/feed/connection.rb', line 24 def ssl_handshake_completed params = { session_key: session, service: Nordnet.config.service } send_data generate(:login, params) end |
#subscribe(args) ⇒ Object
16 17 18 |
# File 'lib/em-nordnet/feed/connection.rb', line 16 def subscribe args send_data generate(:subscribe, args) end |
#unbind ⇒ Object
33 34 35 |
# File 'lib/em-nordnet/feed/connection.rb', line 33 def unbind EventMachine::stop_event_loop end |