Class: Skyfall::Jetstream
Overview
Most of the methods of this class that you might want to use are defined in Stream.
Client of a Jetstream service (JSON-based firehose).
This is an equivalent of Firehose for Jetstream sources, mirroring its API. It returns messages as instances of subclasses of Message, which are generally equivalent to the respective Firehose::Message variants as much as possible.
To connect to a Jetstream websocket, you need to:
-
create an instance of Jetstream, passing it the hostname/URL of the server, and optionally parameters such as cursor or collection/DID filters
-
set up callbacks to be run when connecting, disconnecting, when a message is received etc. (you need to set at least a message handler)
-
call Stream#connect to start the connection
-
handle the received messages
Defined Under Namespace
Classes: AccountMessage, CommitMessage, IdentityMessage, Message, Operation, UnknownMessage
Constant Summary
Constants inherited from Stream
Stream::MAX_RECONNECT_INTERVAL
Instance Attribute Summary collapse
-
#cursor ⇒ Integer?
Current cursor (time of the last seen message).
Attributes inherited from Stream
#auto_reconnect, #check_heartbeat, #heartbeat_interval, #heartbeat_timeout, #last_update, #user_agent
Instance Method Summary collapse
-
#initialize(server, params = {}) ⇒ Jetstream
constructor
A new instance of Jetstream.
Methods inherited from Stream
#connect, #default_user_agent, #disconnect, #inspect, #on_connect, #on_connecting, #on_disconnect, #on_error, #on_message, #on_raw_message, #on_reconnect, #on_timeout, #reconnect, #version_string
Constructor Details
#initialize(server, params = {}) ⇒ Jetstream
Returns a new instance of Jetstream.
82 83 84 85 86 87 88 89 |
# File 'lib/skyfall/jetstream.rb', line 82 def initialize(server, params = {}) require_relative 'jetstream/message' super(server) @params = check_params(params) @cursor = @params.delete(:cursor) @root_url = ensure_empty_path(@root_url) end |
Instance Attribute Details
#cursor ⇒ Integer?
Current cursor (time of the last seen message)
62 63 64 |
# File 'lib/skyfall/jetstream.rb', line 62 def cursor @cursor end |