Class: Skyfall::Jetstream
Defined Under Namespace
Classes: AccountMessage, CommitMessage, IdentityMessage, Message, Operation, UnknownMessage
Constant Summary
Constants inherited from Stream
Stream::EVENTS, Stream::MAX_RECONNECT_INTERVAL
Instance Attribute Summary collapse
-
#cursor ⇒ Object
Returns the value of attribute cursor.
Attributes inherited from Stream
#auto_reconnect, #check_heartbeat, #heartbeat_interval, #heartbeat_timeout, #last_update, #user_agent
Instance Method Summary collapse
- #handle_message(msg) ⇒ Object
-
#initialize(server, params = {}) ⇒ Jetstream
constructor
A new instance of Jetstream.
Methods inherited from Stream
#connect, #default_user_agent, #disconnect, #inspect, #inspectable_variables, #reconnect, #start_heartbeat_timer, #stop_heartbeat_timer, #version_string
Constructor Details
#initialize(server, params = {}) ⇒ Jetstream
11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/skyfall/jetstream.rb', line 11 def initialize(server, params = {}) require_relative 'jetstream/message' super(server) @root_url = @root_url.chomp('/') if URI(@root_url).path != '' raise ArgumentError, "Server parameter should not include any path" end @params = check_params(params) @cursor = @params.delete(:cursor) end |
Instance Attribute Details
#cursor ⇒ Object
Returns the value of attribute cursor.
9 10 11 |
# File 'lib/skyfall/jetstream.rb', line 9 def cursor @cursor end |
Instance Method Details
#handle_message(msg) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/skyfall/jetstream.rb', line 25 def (msg) data = msg.data @handlers[:raw_message]&.call(data) if @handlers[:message] = Message.new(data) @cursor = .time_us @handlers[:message].call() else @cursor = nil end end |