Class: Cloudflare::RealtimeKit::ActiveLivestreamSession
- Inherits:
-
Cloudflare::Resource
- Object
- Cloudflare::Resource
- Cloudflare::RealtimeKit::ActiveLivestreamSession
- Defined in:
- lib/cloudflare/realtime_kit/active_livestream_session.rb
Overview
A livestream’s currently-active session. Singleton — there’s at most one active session per livestream. Reached via livestream.active_session, which returns a stub that auto-fetches on first attribute read.
The response bundles two sub-objects: livestream (the broadcast configuration: ingest server, stream key, playback URL) and session (the runtime: started_time, viewer_seconds, status). Both are returned as typed instances of Livestream and LivestreamSession — partial copies of those schemas, but typed access reads better than Hash bracketing, and the returned instances carry enough scope to call #reload against their canonical endpoints if you want a full refresh.
active = livestream.active_session
active.livestream.stream_key # → String
active.session.viewer_seconds # → Integer
active.livestream.reload # → fetches /livestreams/{id} for the full record
Constant Summary
Constants inherited from Cloudflare::Resource
Cloudflare::Resource::ENVELOPE_KEYS
Instance Attribute Summary
Attributes inherited from Cloudflare::Resource
Instance Method Summary collapse
-
#livestream ⇒ Object
Override the default attribute readers: instead of returning the raw Hash sub-object, hand back a typed Livestream / LivestreamSession scoped to the same app so the caller can keep operating on it.
- #session ⇒ Object
Methods inherited from Cloudflare::Resource
#==, #[], all, attribute, attributes, #attributes, collection_path, configured_api_token, create, #destroy, find, has_many, has_one, #hash, #id, #initialize, member_path, read_only, read_only?, #reload, request, scope_params, scope_required, #set_attrs_from_response, #to_h, to_wire_keys, unwrap_envelope, #update, wire_kwarg, wire_name_for_request, wire_name_for_response
Constructor Details
This class inherits a constructor from Cloudflare::Resource
Instance Method Details
#livestream ⇒ Object
Override the default attribute readers: instead of returning the raw Hash sub-object, hand back a typed Livestream / LivestreamSession scoped to the same app so the caller can keep operating on it.
26 27 28 29 30 |
# File 'lib/cloudflare/realtime_kit/active_livestream_session.rb', line 26 def livestream ensure_loaded! raw = @attrs["livestream"] raw && Livestream.new(raw, scope: parent_scope) end |
#session ⇒ Object
32 33 34 35 36 |
# File 'lib/cloudflare/realtime_kit/active_livestream_session.rb', line 32 def session ensure_loaded! raw = @attrs["session"] raw && LivestreamSession.new(raw, scope: parent_scope) end |