Class: Cloudflare::RealtimeKit::ActiveSession

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

Overview

A meeting’s currently-running session. Modeled as a singleton: every meeting has at most one active session at a time. Reached via meeting.active_session, which auto-loads the session attributes on first access and caches them.

active = meeting.active_session
active.live_participants
active.kick(participant_ids: [ "p-1" ])
active.mute_all(allow_unmute: false)
active.create_poll(question: "Lunch?", options: [ "Pizza", "Salad" ])

kick_all and mute_all act on every participant; the others target specific ids (or custom_participant_ids if you assigned them at invite time).

Constant Summary

Constants inherited from Cloudflare::Resource

Cloudflare::Resource::ENVELOPE_KEYS

Instance Attribute Summary

Attributes inherited from Cloudflare::Resource

#scope

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

Instance Method Details

#create_poll(question:, options:, anonymous: nil, hide_votes: nil) ⇒ Object

POST …/active-session/poll — broadcast a poll to participants.



62
63
64
65
# File 'lib/cloudflare/realtime_kit/active_session.rb', line 62

def create_poll(question:, options:, anonymous: nil, hide_votes: nil)
  Connection.instance.request(:post, "#{member_path}/poll",
    body: { question: question, options: options, anonymous: anonymous, hide_votes: hide_votes })
end

#kick(participant_ids:, custom_participant_ids:) ⇒ Object

POST …/active-session/kick — remove specified participants.



38
39
40
41
# File 'lib/cloudflare/realtime_kit/active_session.rb', line 38

def kick(participant_ids:, custom_participant_ids:)
  Connection.instance.request(:post, "#{member_path}/kick",
    body: { participant_ids: participant_ids, custom_participant_ids: custom_participant_ids })
end

#kick_allObject

POST …/active-session/kick-all — remove every participant.



44
45
46
# File 'lib/cloudflare/realtime_kit/active_session.rb', line 44

def kick_all
  Connection.instance.request(:post, "#{member_path}/kick-all")
end

#mute(participant_ids:, custom_participant_ids:) ⇒ Object

POST …/active-session/mute — mute specified participants.



49
50
51
52
# File 'lib/cloudflare/realtime_kit/active_session.rb', line 49

def mute(participant_ids:, custom_participant_ids:)
  Connection.instance.request(:post, "#{member_path}/mute",
    body: { participant_ids: participant_ids, custom_participant_ids: custom_participant_ids })
end

#mute_all(allow_unmute:) ⇒ Object

POST …/active-session/mute-all — mute every participant. allow_unmute controls whether participants can re-enable their mic.



56
57
58
59
# File 'lib/cloudflare/realtime_kit/active_session.rb', line 56

def mute_all(allow_unmute:)
  Connection.instance.request(:post, "#{member_path}/mute-all",
    body: { allow_unmute: allow_unmute })
end