Class: Cloudflare::RealtimeKit::Session

Inherits:
Cloudflare::Resource show all
Defined in:
lib/cloudflare/realtime_kit/session.rb

Overview

A historical session — the record of what happened when participants joined a meeting. Sessions are read-only from the SDK; they’re created automatically by the platform when a meeting goes live.

session = Session.find("sess-1", app_id: "app-1")
session.participants.all
session.chat       # → Chat (loaded)
session.summary    # → Summary (loaded)
session.transcript # → Transcript (loaded)

Session.find_participant_by_peer_id does a reverse lookup from a peer-level identifier (e.g., what you get from a webhook payload) back to participant data, scoped only to the app — no session id needed.

Constant Summary

Constants inherited from Cloudflare::Resource

Cloudflare::Resource::ENVELOPE_KEYS

Instance Attribute Summary

Attributes inherited from Cloudflare::Resource

#scope

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Cloudflare::Resource

#==, #[], all, attribute, attributes, #attributes, collection_path, create, #destroy, find, has_many, has_one, #hash, #id, #initialize, member_path, read_only, read_only?, #reload, 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

Class Method Details

.find_participant_by_peer_id(peer_id, app_id:, account_id: nil, filters: nil) ⇒ Object

GET /sessions/peer-report/peer_id — reverse lookup from a peer id. Returns participant-shaped data, not a session, so we expose it as a SessionParticipant instance.



44
45
46
47
48
49
50
# File 'lib/cloudflare/realtime_kit/session.rb', line 44

def find_participant_by_peer_id(peer_id, app_id:, account_id: nil, filters: nil)
  scope = build_scope(account_id: , app_id: app_id)
  path  = interpolate("/accounts/{account_id}/realtime/kit/{app_id}/sessions/peer-report/{peer_id}",
                      scope.merge(peer_id: peer_id))
  response = Connection.instance.request(:get, path, params: { filters: filters })
  SessionParticipant.new(response, scope: scope)
end

Instance Method Details

#livestream_sessions(page_no: nil, per_page: nil) ⇒ Object

GET /sessions/session_id/livestream-sessions — paginated list of broadcast sessions associated with this historical session. Returns a plain Array of LivestreamSession instances (not a Relation): the per-session collection lives at a different parent path than the global /livestreams/sessions/{id} that LivestreamSession.find uses, so the two endpoints don’t share scope and Relation can’t model them together cleanly.



60
61
62
63
64
65
66
# File 'lib/cloudflare/realtime_kit/session.rb', line 60

def livestream_sessions(page_no: nil, per_page: nil)
  response = Connection.instance.request(:get, "#{member_path}/livestream-sessions",
    params: { page_no: page_no, per_page: per_page })
  Array(self.class.unwrap_envelope(response)).map do |item|
    LivestreamSession.new(item, scope: { account_id: @scope[:account_id], app_id: @scope[:app_id] })
  end
end