← Cloudflare Realtime / realtime / realtimekit / core
Ukončení relace
Chcete-li ukončit aktuální relace pro všechny účastníky odeberte všechny účastníky pomocí kickAll(). Zastaví jakékoli probíhající nahrávání dané relace a nastaví stav relace na ENDED.
Ukončení relace se liší od opuštění schůzky. Opuštění odpojí pouze aktuálního účastníka. Pokud jsou stále přítomní další účastníci, relace zůstává aktivní.
Kroky
-
Zkontrolujte, zda má místní účastník oprávnění odebírat účastníky.
const canEndSession = meeting.self.permissions.kickParticipant === true; if (!canEndSession) { // Disable the "End meeting/session" control in your UI. // You can also show a message to explain why the action is not available. }const canEndSession = meeting.self.permissions.kickParticipant === true; if (!canEndSession) { // Disable the "End meeting/session" control in your UI. // You can also show a message to explain why the action is not available. }const canEndSession = meeting.self.permissions.kickParticipant === true; if (!canEndSession) { // Disable the "End meeting/session" control in your UI. // You can also show a message to explain why the action is not available. }val canEndSession = meeting.localUser.permissions.host.canKickParticipant if (!canEndSession) { // Disable the "End meeting/session" control in your UI. // You can also show a message to explain why the action is not available. }let canEndSession = meeting.localUser.permissions.host.canKickParticipant if !canEndSession { // Disable the "End meeting/session" control in your UI. // You can also show a message to explain why the action is not available. }const canEndSession = meeting.self.permissions.kickParticipant === true; if (!canEndSession) { // Disable the "End meeting/session" control in your UI. // You can also show a message to explain why the action is not available. } -
Ukončete relaci odebráním všech účastníků.
Pokud účastník nemá požadované oprávnění,
kickAll()vyvolá chybu ClientError s kódem chyby1201.try { await meeting.participants.kickAll(); } catch (err) { if (err?.code === 1201) { // The participant does not have permission to end the session. // Update your UI to indicate that the action is not allowed. return; } throw err; }Pokud účastník nemá požadované oprávnění,
kickAll()vyvolá chybu ClientError s kódem chyby1201.try { await meeting.participants.kickAll(); } catch (err) { if (err?.code === 1201) { // The participant does not have permission to end the session. // Update your UI to indicate that the action is not allowed. return; } throw err; }Pokud účastník nemá požadované oprávnění,
kickAll()vyvolá chybu ClientError s kódem chyby1201.try { await meeting.participants.kickAll(); } catch (err) { if (err?.code === 1201) { // The participant does not have permission to end the session. // Update your UI to indicate that the action is not allowed. return; } throw err; }Pokud účastník nemá požadované oprávnění,
kickAll()vracíHostError.val error: HostError? = meeting.participants.kickAll() if (error != null) { when (error) { is HostError.KickPermissionDenied -> { // The participant does not have permission to end the session. // Update your UI to indicate that the action is not allowed. } } } else { // Successfully initiated session end }Pokud účastník nemá požadované oprávnění,
kickAll()vracíHostError.let error: HostError? = meeting.participants.kickAll() if let error = error { switch error { case .kickPermissionDenied: // The participant does not have permission to end the session. // Update your UI to indicate that the action is not allowed. break default: break } } else { // Successfully initiated session end }Pokud účastník nemá požadované oprávnění,
kickAll()vyvolá chybu ClientError s kódem chyby1201.try { await meeting.participants.kickAll(); } catch (err) { if (err?.code === 1201) { // The participant does not have permission to end the session. // Update your UI to indicate that the action is not allowed. return; } throw err; } -
Naslouchejte události ukončení relace.
Když relace skončí, všichni účastníci relaci opustí. SDK vyvolá
roomLeftudálost sstatenastaveno naended.meeting.self.on("roomLeft", ({ state }) => { if (state === "ended") { // Update your UI to show that the meeting session has ended. } });Když relace skončí, všichni účastníci relaci opustí. SDK vyvolá
roomLeftudálost sstatenastaveno naended.meeting.self.on("roomLeft", ({ state }) => { if (state === "ended") { // Update your UI to show that the meeting session has ended. } });Když relace skončí, všichni účastníci relaci opustí. SDK vyvolá
roomLeftudálost sstatenastaveno naended.meeting.self.on("roomLeft", ({ state }) => { if (state === "ended") { // Update your UI to show that the meeting session has ended. } });Když relace skončí, všichni účastníci relaci opustí. Ukončení relace můžete zpracovat přihlášením k odběru posluchačů událostí.
meeting.addMeetingRoomEventListener(object : RtkMeetingRoomEventListener { override fun onMeetingEnded() { // Update your UI to show that the meeting session has ended. } })Když relace skončí, všichni účastníci relaci opustí. Ukončení relace můžete zpracovat přihlášením k odběru posluchačů událostí.
// Implement the delegate method extension MeetingViewModel: RtkMeetingRoomEventListener { func onMeetingEnded() { // Update your UI to show that the meeting session has ended. } } meeting.addMeetingRoomEventListener(meetingRoomEventListener: self)Když relace skončí, všichni účastníci relaci opustí. SDK vyvolá
roomLeftudálost sstatenastaveno naended.meeting.self.on("roomLeft", ({ state }) => { if (state === "ended") { // Update your UI to show that the meeting session has ended. } });
Relaci můžete z backendu ukončit také odebráním všech účastníků pomocí Vyhodit všechny účastníky API.
Ukončení relace z vašeho backendu
Odebrání všech účastníků pomocí API
Použijte Vyhodit všechny účastníky API metoda pro odebrání všech účastníků z aktivní relace schůzky.
Požadovaná oprávnění API tokenu
Alespoň jeden z následujících oprávnění tokenu je povinné:Realtime AdminRealtime
curl "https://api.cloudflare.com/client/v4/accounts/$ACCOUNT_ID/realtime/kit/$APP_ID/meetings/$MEETING_ID/active-session/kick-all" \
--request POST \
--header "Authorization: Bearer $CLOUDFLARE_API_TOKEN"Naslouchejte událostem ukončení relace pomocí webhooků
Zaregistrujte webhook, který odebírá meeting.ended. RealtimeKit odešle tuto událost při ukončení relace.
Můžete ji použít ke spuštění backendových procesů, jako je odeslání oznámení, generování reportu nebo aktualizace záznamů relace ve vaší databázi.
Požadovaná oprávnění API tokenu
Alespoň jeden z následujících oprávnění tokenu je povinné:Realtime AdminRealtime
curl "https://api.cloudflare.com/client/v4/accounts/$ACCOUNT_ID/realtime/kit/$APP_ID/webhooks" \
--request POST \
--header "Authorization: Bearer $CLOUDFLARE_API_TOKEN" \
--json '{
"name": "Session ended webhook",
"url": "<YOUR_WEBHOOK_URL>",
"events": [
"meeting.ended"
]
}'Vypnutí schůzky
Ukončení relace schůzku nedeaktivuje. Účastníci se mohou znovu připojit ke schůzce a zahájit novou relaci.
Abyste účastníkům zabránili v opětovném připojení a zahájení nové relace, nastavte stav schůzky na INACTIVE pomocí Aktualizujte schůzku API.
Požadovaná oprávnění API tokenu
Alespoň jeden z následujících oprávnění tokenu je povinné:Realtime AdminRealtime
curl "https://api.cloudflare.com/client/v4/accounts/$ACCOUNT_ID/realtime/kit/$APP_ID/meetings/$MEETING_ID" \
--request PATCH \
--header "Authorization: Bearer $CLOUDFLARE_API_TOKEN" \
--json '{
"status": "INACTIVE"
}'Další kroky
- Jak předvolby řídí oprávnění, zjistíte v Preset.
- Možné hodnoty stavu místnosti místního účastníka najdete v Lokální účastník.