Per le app
Videochiamate di gruppo per la tua app
Un’API e un SDK per videoconferenze per Next.js, Laravel, Django e qualsiasi altro stack. Riunioni, lezioni, panel e stanze audio girano sui nostri media server, senza limiti di persone in una chiamata, e la schermata di chiamata è pronta da usare, così non hai nessun media server da gestire.
I prezzi migliori per WebSocket, chiamate 1 a 1 illimitate con server TURN in tutto il mondo, e chiamate di gruppo e live streaming con una quota inclusa. Da $11.99 al mese per 1000 connessioni simultanee, con fatturazione annuale, o $14.99 con fatturazione mensile.
Chiamate di gruppo oltre il tuo piano: $0.20 ogni 1.000 minuti, $0.10 in audio.
Next.js sul server e React nella pagina.
export async function GET( request: Request ) {
const me = await currentUserId();
const id = new URL( request.url ).searchParams.get( 'id' )!;
// Your own check: only its team, and its lead is the host.
if ( ! me || ! await isMemberOf( id, me ) ) {
return new Response( null, { status: 403 } );
}
const token = await realtime.groupCallToken( me, 'meeting:' + id, {
admin: await isLeadOf( id, me ),
} );
return Response.json( { token } );
}app.get( '/api/meeting-token', async ( req, res ) => {
const me = userOf( req );
const { id } = req.query;
// Your own check: only its team, and its lead is the host.
if ( ! me || ! await isMemberOf( id, me ) ) {
return res.sendStatus( 403 );
}
const token = await realtime.groupCallToken( me, 'meeting:' + id, {
admin: await isLeadOf( id, me ),
} );
res.json( { token } );
} );import { createServer } from 'node:http';
createServer( async ( req, res ) => {
const url = new URL( req.url, 'http://localhost' );
if ( url.pathname === '/api/meeting-token' ) {
const me = userOf( req );
const id = url.searchParams.get( 'id' );
// Your own check: only its team, and its lead is the host.
if ( ! me || ! await isMemberOf( id, me ) ) {
res.writeHead( 403 );
return res.end();
}
const token = await realtime.groupCallToken( me, 'meeting:' + id, {
admin: await isLeadOf( id, me ),
} );
res.writeHead( 200, { 'Content-Type': 'application/json' } );
return res.end( JSON.stringify( { token } ) );
}
// Your pages, and realtime.node( userOf ) for the SDK's routes.
} ).listen( 3000 );use Illuminate\Http\Request;
use WordPlus\Realtime\Laravel\Facades\Realtime;
Route::get( '/api/meeting-token', function ( Request $request ) {
$me = $request->user()->id;
$id = $request->query( 'id' );
// Your own check: only its team, and its lead is the host.
abort_unless( is_member_of( $id, $me ), 403 );
return [ 'token' => Realtime::groupCallToken( $me, 'meeting:' . $id, [
'admin' => is_lead_of( $id, $me ),
] ) ];
} )->middleware( 'auth' );require __DIR__ . '/../src/realtime.php';
$me = current_user_id();
$id = $_GET['id'] ?? '';
// Your own check: only its team, and its lead is the host.
if ( ! $me || ! is_member_of( $id, $me ) ) {
http_response_code( 403 );
exit;
}
header( 'Content-Type: application/json' );
echo json_encode( [
'token' => $realtime->groupCallToken( $me, 'meeting:' . $id, [
'admin' => is_lead_of( $id, $me ),
] ),
] );from django.contrib.auth.decorators import login_required
from django.http import HttpResponseForbidden, JsonResponse
from .realtime import realtime
# In urls.py: path("api/meeting-token", views.meeting_token)
@login_required
def meeting_token(request):
me = request.user.id
id = request.GET["id"]
# Your own check: only its team, and its lead is the host.
if not is_member_of(id, me):
return HttpResponseForbidden()
token = realtime.group_call_token(
me, "meeting:" + id, admin=is_lead_of(id, me)
)
return JsonResponse({"token": token})from fastapi import Depends, HTTPException
from realtime import realtime
@app.get("/api/meeting-token")
def meeting_token(id: str, me: int = Depends(current_user_id)):
# Your own check: only its team, and its lead is the host.
if not me or not is_member_of(id, me):
raise HTTPException(403)
token = realtime.group_call_token(
me, "meeting:" + id, admin=is_lead_of(id, me)
)
return {"token": token}from flask import abort, request, session
from realtime import realtime
@app.get("/api/meeting-token")
def meeting_token():
me = session.get("user_id")
id = request.args["id"]
# Your own check: only its team, and its lead is the host.
if not me or not is_member_of(id, me):
abort(403)
token = realtime.group_call_token(
me, "meeting:" + id, admin=is_lead_of(id, me)
)
return {"token": token}// http.HandleFunc("GET /api/meeting-token", meetingToken)
func meetingToken(w http.ResponseWriter, r *http.Request) {
me := userOf(r)
id := r.URL.Query().Get("id")
// Your own check: only its team, and its lead is the host.
if me == "" || !isMemberOf(id, me) {
w.WriteHeader(403)
return
}
token := app.GroupCallToken(me, "meeting:"+id, wordplus.GroupPlace{
Admin: isLeadOf(id, me),
Info: profile(me),
})
reply(w, map[string]string{"token": token})
}Hook e componenti per qualsiasi app React, con uno qualsiasi dei server sopra.
import { connect } from '@wordplus/realtime';
const rt = await connect();
// The call window.
await rt.callScreen();
// And in the page:
// <group-call-button call="meeting:7"
// token-url="/api/meeting-token?id=7"
// type="video" title="Daily meeting">
// Join the meeting
// </group-call-button>import { connect } from '@wordplus/realtime';
const rt = await connect();
// The call window.
await rt.callScreen();
// And in the page:
// <group-call-button call="meeting:7"
// token-url="/api/meeting-token?id=7"
// type="video" title="Daily meeting">
// Join the meeting
// </group-call-button>import { connect } from '@wordplus/realtime';
const rt = await connect();
// The call window.
await rt.callScreen();
// And in the page:
// <group-call-button call="meeting:7"
// token-url="/api/meeting-token?id=7"
// type="video" title="Daily meeting">
// Join the meeting
// </group-call-button>import { connect } from '@wordplus/realtime';
const rt = await connect();
// The call window.
await rt.callScreen();
// And in the page:
// <group-call-button call="meeting:7"
// token-url="/api/meeting-token?id=7"
// type="video" title="Daily meeting">
// Join the meeting
// </group-call-button>import { connect } from '@wordplus/realtime';
const rt = await connect();
// The call window.
await rt.callScreen();
// And in the page:
// <group-call-button call="meeting:7"
// token-url="/api/meeting-token?id=7"
// type="video" title="Daily meeting">
// Join the meeting
// </group-call-button>import { connect } from '@wordplus/realtime';
const rt = await connect();
// The call window.
await rt.callScreen();
// And in the page:
// <group-call-button call="meeting:7"
// token-url="/api/meeting-token?id=7"
// type="video" title="Daily meeting">
// Join the meeting
// </group-call-button>import { connect } from '@wordplus/realtime';
const rt = await connect();
// The call window.
await rt.callScreen();
// And in the page:
// <group-call-button call="meeting:7"
// token-url="/api/meeting-token?id=7"
// type="video" title="Daily meeting">
// Join the meeting
// </group-call-button>import { connect } from '@wordplus/realtime';
const rt = await connect();
// The call window.
await rt.callScreen();
// And in the page:
// <group-call-button call="meeting:7"
// token-url="/api/meeting-token?id=7"
// type="video" title="Daily meeting">
// Join the meeting
// </group-call-button>import { connect } from '@wordplus/realtime';
const rt = await connect();
// The call window.
await rt.callScreen();
// And in the page:
// <group-call-button call="meeting:7"
// token-url="/api/meeting-token?id=7"
// type="video" title="Daily meeting">
// Join the meeting
// </group-call-button><group-call-button call="meeting:7" token-url="/api/meeting-token?id=7" type="video" title="Daily meeting">
Join the meeting
</group-call-button>
<script type="module">
// The call window, on every page a meeting may open from.
await window.Echo.connector.rt.callScreen();
</script>'use client'; // in Next.js
import { CallScreen, GroupCallButton } from '@wordplus/realtime/react';
// Inside <RealtimeProvider>, once for the whole app.
export function JoinMeeting() {
return (
<>
<CallScreen />
<GroupCallButton call="meeting:7" tokenUrl="/api/meeting-token?id=7" type="video" title="Daily meeting">
Join the meeting
</GroupCallButton>
</>
);
}<script setup>
import { watchEffect } from 'vue';
import { useRealtime } from '@wordplus/realtime/vue';
// provideRealtime() once, in your root component.
const rt = useRealtime();
// The call window, on every page a meeting may open from.
watchEffect( () => rt.value?.callScreen() );
</script>
<!-- isCustomElement for this tag, in vite.config.js -->
<template>
<group-call-button call="meeting:7" token-url="/api/meeting-token?id=7" type="video" title="Daily meeting">
Join the meeting
</group-call-button>
</template><script>
import { useRealtime } from '@wordplus/realtime/svelte';
// provideRealtime() once, in your root component.
const rt = useRealtime();
// The call window, on every page a meeting may open from.
$effect( () => { rt.current?.callScreen(); } );
</script>
<group-call-button call="meeting:7" token-url="/api/meeting-token?id=7" type="video" title="Daily meeting">
Join the meeting
</group-call-button>import { Component, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
// realtime.ts, one connection for the whole app:
// export const realtime = connect();
import { realtime } from './realtime';
@Component( {
selector: 'app-join-meeting',
schemas: [ CUSTOM_ELEMENTS_SCHEMA ],
template: `<group-call-button call="meeting:7" token-url="/api/meeting-token?id=7" type="video" title="Daily meeting">Join the meeting</group-call-button>`,
} )
export class JoinMeetingComponent {
async ngOnInit() {
const rt = await realtime;
// The call window, on every page a meeting may open from.
await rt.callScreen();
}
}import WordPlusRealtimeCalls
import WordPlusRealtimeUI
let token = try await api.meetingToken(id: 7) // your own request to your route
let meeting = try await rt.joinGroupCall(token)
CallScreen.shared.show(meeting, title: "Daily meeting")import cloud.wordplus.realtime.calls.joinGroupCall
import cloud.wordplus.realtime.ui.CallScreen
val token = api.meetingToken(id = 7) // your own request to your route
val meeting = rt.joinGroupCall(context, token)
CallScreen.show(context, meeting, title = "Daily meeting")import {
CallScreen, GroupCallButton, RealtimeProvider,
} from '@wordplus/realtime-react-native';
// Your server, in full, as an app has no address of its own.
const API = 'https://app.example.com/api';
const options = {
app: 's1500000007',
endpoint: API + '/realtime',
headers: { Authorization: 'Bearer ' + session.token },
};
export function App() {
return (
<RealtimeProvider options={ options }>
<CallScreen />
<GroupCallButton call="meeting:7" type="video" title="Daily meeting"
tokenUrl={ API + '/meeting-token?id=7' }>
Join the meeting
</GroupCallButton>
</RealtimeProvider>
);
}import 'package:flutter/material.dart';
import 'package:wordplus_realtime/wordplus_realtime.dart';
// Your server, in full, as an app has no address of its own.
const api = 'https://app.example.com/api';
// Once, as your app starts.
final rt = await WordPlusRealtime.connect(
app: 's1500000007',
endpoint: '$api/realtime',
headers: {'Authorization': 'Bearer ${session.token}'},
);
// The call window.
await rt.callScreen();
// In your build:
GroupCallButton(
rt: rt,
call: 'meeting:7',
tokenUrl: '$api/meeting-token?id=7',
title: 'Daily meeting',
child: const Text('Join the meeting'),
)Prova una chiamata di gruppo
Apri una stanza qui, poi fai entrare fino a tre persone dai loro telefoni o da altre finestre. Nessun account necessario.
Queste sono le schermate che l’SDK dà alla tua app. Il browser chiede fotocamera e microfono, non viene registrato nulla e la demo termina dopo 10 minuti.
Chiamate di gruppo
Chiamate di gruppo sui nostri media server
Riunioni, lezioni, panel e stanze audio girano sui nostri media server, non tra i dispositivi, così ogni dispositivo invia la sua fotocamera una volta sola, per quante persone ci siano nella chiamata.

Nessun limite di persone
Ogni persona in una chiamata di gruppo invia la sua fotocamera, il suo microfono e il suo schermo una volta sola, e i nostri media server li passano a tutti gli altri, in più regioni.
Relatori e ascoltatori
Il tuo server dice chi trasmette e chi guarda e ascolta soltanto, come in una lezione o in un panel. Un host fa parlare un ascoltatore e poi lo rimette ad ascoltare.
Gli host tengono l’ordine
Un host spegne un microfono, fa parlare qualcuno e toglie qualcuno dalla chiamata, dal riquadro di ogni persona.
Decide il tuo server
Gestisci una riunione, dall’inizio alla fine
Il tuo server dice chi entra e chi fa da host, e la pagina o il tuo server fanno il resto. Ecco una riunione di team, poi una lezione, un’attività alla volta.
Next.js sul server e React nella pagina.
Dai un token alla pagina
Una chiamata di gruppo è solo un nome, come meeting:7, senza nulla da creare nel cloud. Chi entra e chi fa da host è logica della tua app, quindi sta in una tua route, che risponde con un token. isMemberOf e isLeadOf sono verifiche tue.
export async function GET( request: Request ) {
const me = await currentUserId();
const id = new URL( request.url ).searchParams.get( 'id' )!;
// Your own check: only its team, and its lead is the host.
if ( ! me || ! await isMemberOf( id, me ) ) {
return new Response( null, { status: 403 } );
}
const token = await realtime.groupCallToken( me, 'meeting:' + id, {
admin: await isLeadOf( id, me ),
} );
return Response.json( { token } );
}app.get( '/api/meeting-token', async ( req, res ) => {
const me = userOf( req );
const { id } = req.query;
// Your own check: only its team, and its lead is the host.
if ( ! me || ! await isMemberOf( id, me ) ) {
return res.sendStatus( 403 );
}
const token = await realtime.groupCallToken( me, 'meeting:' + id, {
admin: await isLeadOf( id, me ),
} );
res.json( { token } );
} );import { createServer } from 'node:http';
createServer( async ( req, res ) => {
const url = new URL( req.url, 'http://localhost' );
if ( url.pathname === '/api/meeting-token' ) {
const me = userOf( req );
const id = url.searchParams.get( 'id' );
// Your own check: only its team, and its lead is the host.
if ( ! me || ! await isMemberOf( id, me ) ) {
res.writeHead( 403 );
return res.end();
}
const token = await realtime.groupCallToken( me, 'meeting:' + id, {
admin: await isLeadOf( id, me ),
} );
res.writeHead( 200, { 'Content-Type': 'application/json' } );
return res.end( JSON.stringify( { token } ) );
}
// Your pages, and realtime.node( userOf ) for the SDK's routes.
} ).listen( 3000 );use Illuminate\Http\Request;
use WordPlus\Realtime\Laravel\Facades\Realtime;
Route::get( '/api/meeting-token', function ( Request $request ) {
$me = $request->user()->id;
$id = $request->query( 'id' );
// Your own check: only its team, and its lead is the host.
abort_unless( is_member_of( $id, $me ), 403 );
return [ 'token' => Realtime::groupCallToken( $me, 'meeting:' . $id, [
'admin' => is_lead_of( $id, $me ),
] ) ];
} )->middleware( 'auth' );require __DIR__ . '/../src/realtime.php';
$me = current_user_id();
$id = $_GET['id'] ?? '';
// Your own check: only its team, and its lead is the host.
if ( ! $me || ! is_member_of( $id, $me ) ) {
http_response_code( 403 );
exit;
}
header( 'Content-Type: application/json' );
echo json_encode( [
'token' => $realtime->groupCallToken( $me, 'meeting:' . $id, [
'admin' => is_lead_of( $id, $me ),
] ),
] );from django.contrib.auth.decorators import login_required
from django.http import HttpResponseForbidden, JsonResponse
from .realtime import realtime
# In urls.py: path("api/meeting-token", views.meeting_token)
@login_required
def meeting_token(request):
me = request.user.id
id = request.GET["id"]
# Your own check: only its team, and its lead is the host.
if not is_member_of(id, me):
return HttpResponseForbidden()
token = realtime.group_call_token(
me, "meeting:" + id, admin=is_lead_of(id, me)
)
return JsonResponse({"token": token})from fastapi import Depends, HTTPException
from realtime import realtime
@app.get("/api/meeting-token")
def meeting_token(id: str, me: int = Depends(current_user_id)):
# Your own check: only its team, and its lead is the host.
if not me or not is_member_of(id, me):
raise HTTPException(403)
token = realtime.group_call_token(
me, "meeting:" + id, admin=is_lead_of(id, me)
)
return {"token": token}from flask import abort, request, session
from realtime import realtime
@app.get("/api/meeting-token")
def meeting_token():
me = session.get("user_id")
id = request.args["id"]
# Your own check: only its team, and its lead is the host.
if not me or not is_member_of(id, me):
abort(403)
token = realtime.group_call_token(
me, "meeting:" + id, admin=is_lead_of(id, me)
)
return {"token": token}// http.HandleFunc("GET /api/meeting-token", meetingToken)
func meetingToken(w http.ResponseWriter, r *http.Request) {
me := userOf(r)
id := r.URL.Query().Get("id")
// Your own check: only its team, and its lead is the host.
if me == "" || !isMemberOf(id, me) {
w.WriteHeader(403)
return
}
token := app.GroupCallToken(me, "meeting:"+id, wordplus.GroupPlace{
Admin: isLeadOf(id, me),
Info: profile(me),
})
reply(w, map[string]string{"token": token})
}Aggiungi un pulsante per entrare
La schermata pronta: un pulsante e una finestra di chiamata con ogni riquadro e comando, senza codice di chiamata. Il pulsante chiede il suo token alla tua route.
Hook e componenti per qualsiasi app React, con uno qualsiasi dei server sopra.
import { connect } from '@wordplus/realtime';
const rt = await connect();
// The call window, on every page a meeting may open from.
await rt.callScreen();
// And in the page. The button asks your route for its token.
// <group-call-button call="meeting:7" token-url="/api/meeting-token?id=7" type="video" title="Daily meeting">
// Join the meeting
// </group-call-button>import { connect } from '@wordplus/realtime';
const rt = await connect();
// The call window, on every page a meeting may open from.
await rt.callScreen();
// And in the page. The button asks your route for its token.
// <group-call-button call="meeting:7" token-url="/api/meeting-token?id=7" type="video" title="Daily meeting">
// Join the meeting
// </group-call-button>import { connect } from '@wordplus/realtime';
const rt = await connect();
// The call window, on every page a meeting may open from.
await rt.callScreen();
// And in the page. The button asks your route for its token.
// <group-call-button call="meeting:7" token-url="/api/meeting-token?id=7" type="video" title="Daily meeting">
// Join the meeting
// </group-call-button>import { connect } from '@wordplus/realtime';
const rt = await connect();
// The call window, on every page a meeting may open from.
await rt.callScreen();
// And in the page. The button asks your route for its token.
// <group-call-button call="meeting:7" token-url="/api/meeting-token?id=7" type="video" title="Daily meeting">
// Join the meeting
// </group-call-button>import { connect } from '@wordplus/realtime';
const rt = await connect();
// The call window, on every page a meeting may open from.
await rt.callScreen();
// And in the page. The button asks your route for its token.
// <group-call-button call="meeting:7" token-url="/api/meeting-token?id=7" type="video" title="Daily meeting">
// Join the meeting
// </group-call-button>import { connect } from '@wordplus/realtime';
const rt = await connect();
// The call window, on every page a meeting may open from.
await rt.callScreen();
// And in the page. The button asks your route for its token.
// <group-call-button call="meeting:7" token-url="/api/meeting-token?id=7" type="video" title="Daily meeting">
// Join the meeting
// </group-call-button>import { connect } from '@wordplus/realtime';
const rt = await connect();
// The call window, on every page a meeting may open from.
await rt.callScreen();
// And in the page. The button asks your route for its token.
// <group-call-button call="meeting:7" token-url="/api/meeting-token?id=7" type="video" title="Daily meeting">
// Join the meeting
// </group-call-button>import { connect } from '@wordplus/realtime';
const rt = await connect();
// The call window, on every page a meeting may open from.
await rt.callScreen();
// And in the page. The button asks your route for its token.
// <group-call-button call="meeting:7" token-url="/api/meeting-token?id=7" type="video" title="Daily meeting">
// Join the meeting
// </group-call-button>import { connect } from '@wordplus/realtime';
const rt = await connect();
// The call window, on every page a meeting may open from.
await rt.callScreen();
// And in the page. The button asks your route for its token.
// <group-call-button call="meeting:7" token-url="/api/meeting-token?id=7" type="video" title="Daily meeting">
// Join the meeting
// </group-call-button><group-call-button call="meeting:7" token-url="/api/meeting-token?id=7" type="video" title="Daily meeting">
Join the meeting
</group-call-button>
<script type="module">
// The call window, on every page a meeting may open from.
await window.Echo.connector.rt.callScreen();
</script>'use client'; // in Next.js
import { CallScreen, GroupCallButton } from '@wordplus/realtime/react';
// Inside <RealtimeProvider>, once for the whole app.
export function JoinMeeting() {
return (
<>
<CallScreen />
<GroupCallButton call="meeting:7" tokenUrl="/api/meeting-token?id=7" type="video" title="Daily meeting">
Join the meeting
</GroupCallButton>
</>
);
}<script setup>
import { watchEffect } from 'vue';
import { useRealtime } from '@wordplus/realtime/vue';
// provideRealtime() once, in your root component.
const rt = useRealtime();
// The call window, on every page a meeting may open from.
watchEffect( () => rt.value?.callScreen() );
</script>
<!-- isCustomElement for this tag, in vite.config.js -->
<template>
<group-call-button call="meeting:7" token-url="/api/meeting-token?id=7" type="video" title="Daily meeting">
Join the meeting
</group-call-button>
</template><script>
import { useRealtime } from '@wordplus/realtime/svelte';
// provideRealtime() once, in your root component.
const rt = useRealtime();
// The call window, on every page a meeting may open from.
$effect( () => { rt.current?.callScreen(); } );
</script>
<group-call-button call="meeting:7" token-url="/api/meeting-token?id=7" type="video" title="Daily meeting">
Join the meeting
</group-call-button>import { Component, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
// realtime.ts, one connection for the whole app:
// export const realtime = connect();
import { realtime } from './realtime';
@Component( {
selector: 'app-join-meeting',
schemas: [ CUSTOM_ELEMENTS_SCHEMA ],
template: `<group-call-button call="meeting:7" token-url="/api/meeting-token?id=7" type="video" title="Daily meeting">Join the meeting</group-call-button>`,
} )
export class JoinMeetingComponent {
async ngOnInit() {
const rt = await realtime;
// The call window, on every page a meeting may open from.
await rt.callScreen();
}
}import WordPlusRealtimeCalls
import WordPlusRealtimeUI
let token = try await api.meetingToken(id: 7) // your own request to your route
let meeting = try await rt.joinGroupCall(token)
CallScreen.shared.show(meeting, title: "Daily meeting")import cloud.wordplus.realtime.calls.joinGroupCall
import cloud.wordplus.realtime.ui.CallScreen
val token = api.meetingToken(id = 7) // your own request to your route
val meeting = rt.joinGroupCall(context, token)
CallScreen.show(context, meeting, title = "Daily meeting")import {
CallScreen, GroupCallButton, RealtimeProvider,
} from '@wordplus/realtime-react-native';
// Your server, in full, as an app has no address of its own.
const API = 'https://app.example.com/api';
const options = {
app: 's1500000007',
endpoint: API + '/realtime',
headers: { Authorization: 'Bearer ' + session.token },
};
export function App() {
return (
<RealtimeProvider options={ options }>
<CallScreen />
<GroupCallButton call="meeting:7" type="video" title="Daily meeting"
tokenUrl={ API + '/meeting-token?id=7' }>
Join the meeting
</GroupCallButton>
</RealtimeProvider>
);
}import 'package:flutter/material.dart';
import 'package:wordplus_realtime/wordplus_realtime.dart';
// Your server, in full, as an app has no address of its own.
const api = 'https://app.example.com/api';
// Once, as your app starts.
final rt = await WordPlusRealtime.connect(
app: 's1500000007',
endpoint: '$api/realtime',
headers: {'Authorization': 'Bearer ${session.token}'},
);
// The call window.
await rt.callScreen();
// In your build:
GroupCallButton(
rt: rt,
call: 'meeting:7',
tokenUrl: '$api/meeting-token?id=7',
title: 'Daily meeting',
child: const Text('Join the meeting'),
)Mettila nella tua pagina
La stessa schermata in un posto tuo, invece di una finestra sopra la pagina, ed entra all’apertura della pagina se lo vuoi.
Hook e componenti per qualsiasi app React, con uno qualsiasi dei server sopra.
import { connect } from '@wordplus/realtime';
const rt = await connect();
await rt.callScreen();
// And in the page. The meeting opens here, with no window over it,
// joining as the page opens, the camera and microphone on:
// <call-spot call="meeting:7" token-url="/api/meeting-token?id=7" join="video" join-with="microphone camera"></call-spot>import { connect } from '@wordplus/realtime';
const rt = await connect();
await rt.callScreen();
// And in the page. The meeting opens here, with no window over it,
// joining as the page opens, the camera and microphone on:
// <call-spot call="meeting:7" token-url="/api/meeting-token?id=7" join="video" join-with="microphone camera"></call-spot>import { connect } from '@wordplus/realtime';
const rt = await connect();
await rt.callScreen();
// And in the page. The meeting opens here, with no window over it,
// joining as the page opens, the camera and microphone on:
// <call-spot call="meeting:7" token-url="/api/meeting-token?id=7" join="video" join-with="microphone camera"></call-spot>import { connect } from '@wordplus/realtime';
const rt = await connect();
await rt.callScreen();
// And in the page. The meeting opens here, with no window over it,
// joining as the page opens, the camera and microphone on:
// <call-spot call="meeting:7" token-url="/api/meeting-token?id=7" join="video" join-with="microphone camera"></call-spot>import { connect } from '@wordplus/realtime';
const rt = await connect();
await rt.callScreen();
// And in the page. The meeting opens here, with no window over it,
// joining as the page opens, the camera and microphone on:
// <call-spot call="meeting:7" token-url="/api/meeting-token?id=7" join="video" join-with="microphone camera"></call-spot>import { connect } from '@wordplus/realtime';
const rt = await connect();
await rt.callScreen();
// And in the page. The meeting opens here, with no window over it,
// joining as the page opens, the camera and microphone on:
// <call-spot call="meeting:7" token-url="/api/meeting-token?id=7" join="video" join-with="microphone camera"></call-spot>import { connect } from '@wordplus/realtime';
const rt = await connect();
await rt.callScreen();
// And in the page. The meeting opens here, with no window over it,
// joining as the page opens, the camera and microphone on:
// <call-spot call="meeting:7" token-url="/api/meeting-token?id=7" join="video" join-with="microphone camera"></call-spot>import { connect } from '@wordplus/realtime';
const rt = await connect();
await rt.callScreen();
// And in the page. The meeting opens here, with no window over it,
// joining as the page opens, the camera and microphone on:
// <call-spot call="meeting:7" token-url="/api/meeting-token?id=7" join="video" join-with="microphone camera"></call-spot>import { connect } from '@wordplus/realtime';
const rt = await connect();
await rt.callScreen();
// And in the page. The meeting opens here, with no window over it,
// joining as the page opens, the camera and microphone on:
// <call-spot call="meeting:7" token-url="/api/meeting-token?id=7" join="video" join-with="microphone camera"></call-spot><call-spot call="meeting:7" token-url="/api/meeting-token?id=7" join="video" join-with="microphone camera"></call-spot>
<script type="module">
await window.Echo.connector.rt.callScreen();
</script>'use client'; // in Next.js
import { CallScreen, CallSpot } from '@wordplus/realtime/react';
// Inside <RealtimeProvider>, once for the whole app.
export function Meeting() {
return (
<>
<CallScreen />
<CallSpot call="meeting:7" tokenUrl="/api/meeting-token?id=7" join="video" joinWith="microphone camera" />
</>
);
}<script setup>
import { watchEffect } from 'vue';
import { useRealtime } from '@wordplus/realtime/vue';
// provideRealtime() once, in your root component.
const rt = useRealtime();
watchEffect( () => rt.value?.callScreen() );
</script>
<!-- isCustomElement for this tag, in vite.config.js -->
<template>
<call-spot call="meeting:7" token-url="/api/meeting-token?id=7" join="video" join-with="microphone camera"></call-spot>
</template><script>
import { useRealtime } from '@wordplus/realtime/svelte';
// provideRealtime() once, in your root component.
const rt = useRealtime();
$effect( () => { rt.current?.callScreen(); } );
</script>
<call-spot call="meeting:7" token-url="/api/meeting-token?id=7" join="video" join-with="microphone camera"></call-spot>import { Component, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
// realtime.ts, one connection for the whole app:
// export const realtime = connect();
import { realtime } from './realtime';
@Component( {
selector: 'app-meeting',
schemas: [ CUSTOM_ELEMENTS_SCHEMA ],
template: `<call-spot call="meeting:7" token-url="/api/meeting-token?id=7" join="video" join-with="microphone camera"></call-spot>`,
} )
export class MeetingComponent {
async ngOnInit() {
const rt = await realtime;
await rt.callScreen();
}
}Entra dal tuo codice
Per una schermata che disegni tu: ottieni un token dalla tua route ed entra con quello. Ogni persona arriva con la sua fotocamera e il suo microfono, e non viene inviato nulla finché non lo chiedi.
Hook e componenti per qualsiasi app React, con uno qualsiasi dei server sopra.
import { connect } from '@wordplus/realtime';
const rt = await connect();
// Asks your server for a token: your route from the first step.
async function meetingToken( id ) {
const answer = await fetch( '/api/meeting-token?id=' + id );
if ( ! answer.ok ) throw new Error( 'Your server said no' );
return ( await answer.json() ).token;
}
const group = await rt.joinGroupCall( await meetingToken( 7 ) );
// tileFor() and removeTile() are your own: a <video> for each person.
group.on( 'person', ( person ) => person.camera?.attach( tileFor( person.user ) ) );
group.on( 'person_left', ( person ) => removeTile( person.user ) );
await group.setMicrophone( true );
await group.setCamera( true );
leave.onclick = () => group.leave();import { connect } from '@wordplus/realtime';
const rt = await connect();
// Asks your server for a token: your route from the first step.
async function meetingToken( id ) {
const answer = await fetch( '/api/meeting-token?id=' + id );
if ( ! answer.ok ) throw new Error( 'Your server said no' );
return ( await answer.json() ).token;
}
const group = await rt.joinGroupCall( await meetingToken( 7 ) );
// tileFor() and removeTile() are your own: a <video> for each person.
group.on( 'person', ( person ) => person.camera?.attach( tileFor( person.user ) ) );
group.on( 'person_left', ( person ) => removeTile( person.user ) );
await group.setMicrophone( true );
await group.setCamera( true );
leave.onclick = () => group.leave();import { connect } from '@wordplus/realtime';
const rt = await connect();
// Asks your server for a token: your route from the first step.
async function meetingToken( id ) {
const answer = await fetch( '/api/meeting-token?id=' + id );
if ( ! answer.ok ) throw new Error( 'Your server said no' );
return ( await answer.json() ).token;
}
const group = await rt.joinGroupCall( await meetingToken( 7 ) );
// tileFor() and removeTile() are your own: a <video> for each person.
group.on( 'person', ( person ) => person.camera?.attach( tileFor( person.user ) ) );
group.on( 'person_left', ( person ) => removeTile( person.user ) );
await group.setMicrophone( true );
await group.setCamera( true );
leave.onclick = () => group.leave();import { connect } from '@wordplus/realtime';
const rt = await connect();
// Asks your server for a token: your route from the first step.
async function meetingToken( id ) {
const answer = await fetch( '/api/meeting-token?id=' + id );
if ( ! answer.ok ) throw new Error( 'Your server said no' );
return ( await answer.json() ).token;
}
const group = await rt.joinGroupCall( await meetingToken( 7 ) );
// tileFor() and removeTile() are your own: a <video> for each person.
group.on( 'person', ( person ) => person.camera?.attach( tileFor( person.user ) ) );
group.on( 'person_left', ( person ) => removeTile( person.user ) );
await group.setMicrophone( true );
await group.setCamera( true );
leave.onclick = () => group.leave();import { connect } from '@wordplus/realtime';
const rt = await connect();
// Asks your server for a token: your route from the first step.
async function meetingToken( id ) {
const answer = await fetch( '/api/meeting-token?id=' + id );
if ( ! answer.ok ) throw new Error( 'Your server said no' );
return ( await answer.json() ).token;
}
const group = await rt.joinGroupCall( await meetingToken( 7 ) );
// tileFor() and removeTile() are your own: a <video> for each person.
group.on( 'person', ( person ) => person.camera?.attach( tileFor( person.user ) ) );
group.on( 'person_left', ( person ) => removeTile( person.user ) );
await group.setMicrophone( true );
await group.setCamera( true );
leave.onclick = () => group.leave();import { connect } from '@wordplus/realtime';
const rt = await connect();
// Asks your server for a token: your route from the first step.
async function meetingToken( id ) {
const answer = await fetch( '/api/meeting-token?id=' + id );
if ( ! answer.ok ) throw new Error( 'Your server said no' );
return ( await answer.json() ).token;
}
const group = await rt.joinGroupCall( await meetingToken( 7 ) );
// tileFor() and removeTile() are your own: a <video> for each person.
group.on( 'person', ( person ) => person.camera?.attach( tileFor( person.user ) ) );
group.on( 'person_left', ( person ) => removeTile( person.user ) );
await group.setMicrophone( true );
await group.setCamera( true );
leave.onclick = () => group.leave();import { connect } from '@wordplus/realtime';
const rt = await connect();
// Asks your server for a token: your route from the first step.
async function meetingToken( id ) {
const answer = await fetch( '/api/meeting-token?id=' + id );
if ( ! answer.ok ) throw new Error( 'Your server said no' );
return ( await answer.json() ).token;
}
const group = await rt.joinGroupCall( await meetingToken( 7 ) );
// tileFor() and removeTile() are your own: a <video> for each person.
group.on( 'person', ( person ) => person.camera?.attach( tileFor( person.user ) ) );
group.on( 'person_left', ( person ) => removeTile( person.user ) );
await group.setMicrophone( true );
await group.setCamera( true );
leave.onclick = () => group.leave();import { connect } from '@wordplus/realtime';
const rt = await connect();
// Asks your server for a token: your route from the first step.
async function meetingToken( id ) {
const answer = await fetch( '/api/meeting-token?id=' + id );
if ( ! answer.ok ) throw new Error( 'Your server said no' );
return ( await answer.json() ).token;
}
const group = await rt.joinGroupCall( await meetingToken( 7 ) );
// tileFor() and removeTile() are your own: a <video> for each person.
group.on( 'person', ( person ) => person.camera?.attach( tileFor( person.user ) ) );
group.on( 'person_left', ( person ) => removeTile( person.user ) );
await group.setMicrophone( true );
await group.setCamera( true );
leave.onclick = () => group.leave();import { connect } from '@wordplus/realtime';
const rt = await connect();
// Asks your server for a token: your route from the first step.
async function meetingToken( id ) {
const answer = await fetch( '/api/meeting-token?id=' + id );
if ( ! answer.ok ) throw new Error( 'Your server said no' );
return ( await answer.json() ).token;
}
const group = await rt.joinGroupCall( await meetingToken( 7 ) );
// tileFor() and removeTile() are your own: a <video> for each person.
group.on( 'person', ( person ) => person.camera?.attach( tileFor( person.user ) ) );
group.on( 'person_left', ( person ) => removeTile( person.user ) );
await group.setMicrophone( true );
await group.setCamera( true );
leave.onclick = () => group.leave();const rt = window.Echo.connector.rt; // the connection Echo made
// Asks your server for a token: your route from the first step.
async function meetingToken( id ) {
const answer = await fetch( '/api/meeting-token?id=' + id );
if ( ! answer.ok ) throw new Error( 'Your server said no' );
return ( await answer.json() ).token;
}
const group = await rt.joinGroupCall( await meetingToken( 7 ) );
// tileFor() and removeTile() are your own: a <video> for each person.
group.on( 'person', ( person ) => person.camera?.attach( tileFor( person.user ) ) );
group.on( 'person_left', ( person ) => removeTile( person.user ) );
await group.setMicrophone( true );
await group.setCamera( true );
leave.onclick = () => group.leave();'use client'; // in Next.js
import { AudioTrack, useGroupCall, VideoTrack } from '@wordplus/realtime/react';
// Asks your server for a token: your route from the first step.
async function meetingToken( id ) {
const answer = await fetch( '/api/meeting-token?id=' + id );
if ( ! answer.ok ) throw new Error( 'Your server said no' );
return ( await answer.json() ).token;
}
// Inside <RealtimeProvider>, once for the whole app.
export function Meeting() {
const { people, camera, setCamera, setMicrophone } = useGroupCall( 'meeting:7', () => meetingToken( 7 ) );
return (
<>
{ people.map( ( person ) => (
<div key={ person.user }>
<VideoTrack track={ person.camera } />
<AudioTrack track={ person.microphone } />
</div>
) ) }
<VideoTrack track={ camera } />
<button onClick={ () => setCamera( ! camera ) }>Camera</button>
<button onClick={ () => setMicrophone( true ) }>Microphone</button>
</>
);
}<script setup>
import { AudioTrack, useGroupCall, VideoTrack } from '@wordplus/realtime/vue';
// Asks your server for a token: your route from the first step.
async function meetingToken( id ) {
const answer = await fetch( '/api/meeting-token?id=' + id );
if ( ! answer.ok ) throw new Error( 'Your server said no' );
return ( await answer.json() ).token;
}
// provideRealtime() once, in your root component.
const { people, camera, setCamera, setMicrophone } = useGroupCall( 'meeting:7', () => meetingToken( 7 ) );
</script>
<template>
<div v-for="person in people" :key="person.user">
<VideoTrack :track="person.camera" />
<AudioTrack :track="person.microphone" />
</div>
<VideoTrack :track="camera" />
<button @click="setCamera( ! camera )">Camera</button>
<button @click="setMicrophone( true )">Microphone</button>
</template><script>
import { track, useGroupCall } from '@wordplus/realtime/svelte';
// Asks your server for a token: your route from the first step.
async function meetingToken( id ) {
const answer = await fetch( '/api/meeting-token?id=' + id );
if ( ! answer.ok ) throw new Error( 'Your server said no' );
return ( await answer.json() ).token;
}
// provideRealtime() once, in your root component.
const meeting = useGroupCall( 'meeting:7', () => meetingToken( 7 ) );
</script>
{#each meeting.people as person (person.user)}
<video use:track={ person.camera } muted autoplay playsinline></video>
<audio use:track={ person.microphone } autoplay></audio>
{/each}
<video use:track={ meeting.camera } muted autoplay playsinline></video>
<button onclick={ () => meeting.setCamera( ! meeting.camera ) }>Camera</button>
<button onclick={ () => meeting.setMicrophone( true ) }>Microphone</button>import { Component, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
// realtime.ts, one connection for the whole app:
// export const realtime = connect();
import { realtime } from './realtime';
@Component( {
selector: 'app-meeting',
schemas: [ CUSTOM_ELEMENTS_SCHEMA ],
template: `<!-- Your tiles here -->`,
} )
export class MeetingComponent {
async ngOnInit() {
const rt = await realtime;
// Asks your server for a token: your route from the first step.
async function meetingToken( id ) {
const answer = await fetch( '/api/meeting-token?id=' + id );
if ( ! answer.ok ) throw new Error( 'Your server said no' );
return ( await answer.json() ).token;
}
const group = await rt.joinGroupCall( await meetingToken( 7 ) );
// tileFor() and removeTile() are your own: a <video> for each person.
group.on( 'person', ( person ) => person.camera?.attach( tileFor( person.user ) ) );
group.on( 'person_left', ( person ) => removeTile( person.user ) );
await group.setMicrophone( true );
await group.setCamera( true );
leave.onclick = () => group.leave();
}
}let token = try await api.meetingToken(id: 7) // your own request to your route
let group = try await rt.joinGroupCall(token)
group.setMicrophone(true) // nothing is sent until asked
group.setCamera(true)
// tile(for:) is your own: a GroupVideoView for each person.
group.onPeople {
for person in group.people { tile(for: person).show(person.identity, of: group) }
}
leave.addAction(UIAction { _ in group.leave() }, for: .touchUpInside)val token = api.meetingToken(id = 7) // your own request to your route
val group = rt.joinGroupCall(context, token)
group.setMicrophone(true) // nothing is sent until asked
group.setCamera(true)
// tileFor() is your own: a GroupVideoView for each person.
group.onPeople {
for (person in group.people) tileFor(person).show(person.identity, group)
}
leave.setOnClickListener { group.leave() }import { Button, Text, View } from 'react-native';
import { GroupVideo, useGroupCall, useRealtime } from '@wordplus/realtime-react-native';
const API = 'https://app.example.com/api'; // your server, in full
// Inside <RealtimeProvider>, once for the whole app.
export function Meeting() {
const rt = useRealtime();
// Asks your route from the first step, once connected.
const { group, state, error } = useGroupCall( 'meeting:7', () => rt.tokenFrom( API + '/meeting-token', { id: 7 } ) );
if ( ! state ) return <Text>{ error ?? 'Joining…' }</Text>;
return (
<View>
{ state.people.map( ( person ) => (
<GroupVideo key={ person.identity } group={ group } person={ person.identity } style={ { aspectRatio: 16 / 9 } } />
) ) }
<GroupVideo group={ group } source="own" mirrored style={ { height: 120 } } />
<Button title="Camera" onPress={ () => group.setCamera( ! state.camera ) } />
<Button title="Microphone" onPress={ () => group.setMicrophone( ! state.microphone ) } />
</View>
);
}final token = await rt.tokenFrom('$api/meeting-token', {'id': 7});
final group = await rt.joinGroupCall(token);
await group.setMicrophone(true); // nothing is sent until asked
await group.setCamera(true);
// In your build:
ListenableBuilder(
listenable: group, // someone arrives or leaves, or what they send changes
builder: (context, _) => GridView.count(crossAxisCount: 2, children: [
for (final person in group.people)
GroupVideo(key: ValueKey(person.identity), group: group, person: person.identity),
GroupVideo(group: group, source: GroupVideoSource.own, mirrored: true),
]),
)Fotocamera, microfono e schermo
Gli stessi comandi in una chiamata, in una chiamata di gruppo e in una diretta, così la tua schermata non ha dispositivi da seguire. Una fotocamera si ferma, e la sua spia si spegne, quando viene disattivata o quando la chiamata finisce.
Hook e componenti per qualsiasi app React, con uno qualsiasi dei server sopra.
import { connect } from '@wordplus/realtime';
const rt = await connect();
await group.setMicrophone( false ); // muted
await group.setCamera( false ); // stopped, and the light goes off
const shared = await group.setScreenShare( true ); // false if they picked nothing
// Move to another camera with no gap for the others.
const { cameras } = await group.devices();
await group.setCamera( true, { deviceId: cameras[ 1 ].id } );import { connect } from '@wordplus/realtime';
const rt = await connect();
await group.setMicrophone( false ); // muted
await group.setCamera( false ); // stopped, and the light goes off
const shared = await group.setScreenShare( true ); // false if they picked nothing
// Move to another camera with no gap for the others.
const { cameras } = await group.devices();
await group.setCamera( true, { deviceId: cameras[ 1 ].id } );import { connect } from '@wordplus/realtime';
const rt = await connect();
await group.setMicrophone( false ); // muted
await group.setCamera( false ); // stopped, and the light goes off
const shared = await group.setScreenShare( true ); // false if they picked nothing
// Move to another camera with no gap for the others.
const { cameras } = await group.devices();
await group.setCamera( true, { deviceId: cameras[ 1 ].id } );import { connect } from '@wordplus/realtime';
const rt = await connect();
await group.setMicrophone( false ); // muted
await group.setCamera( false ); // stopped, and the light goes off
const shared = await group.setScreenShare( true ); // false if they picked nothing
// Move to another camera with no gap for the others.
const { cameras } = await group.devices();
await group.setCamera( true, { deviceId: cameras[ 1 ].id } );import { connect } from '@wordplus/realtime';
const rt = await connect();
await group.setMicrophone( false ); // muted
await group.setCamera( false ); // stopped, and the light goes off
const shared = await group.setScreenShare( true ); // false if they picked nothing
// Move to another camera with no gap for the others.
const { cameras } = await group.devices();
await group.setCamera( true, { deviceId: cameras[ 1 ].id } );import { connect } from '@wordplus/realtime';
const rt = await connect();
await group.setMicrophone( false ); // muted
await group.setCamera( false ); // stopped, and the light goes off
const shared = await group.setScreenShare( true ); // false if they picked nothing
// Move to another camera with no gap for the others.
const { cameras } = await group.devices();
await group.setCamera( true, { deviceId: cameras[ 1 ].id } );import { connect } from '@wordplus/realtime';
const rt = await connect();
await group.setMicrophone( false ); // muted
await group.setCamera( false ); // stopped, and the light goes off
const shared = await group.setScreenShare( true ); // false if they picked nothing
// Move to another camera with no gap for the others.
const { cameras } = await group.devices();
await group.setCamera( true, { deviceId: cameras[ 1 ].id } );import { connect } from '@wordplus/realtime';
const rt = await connect();
await group.setMicrophone( false ); // muted
await group.setCamera( false ); // stopped, and the light goes off
const shared = await group.setScreenShare( true ); // false if they picked nothing
// Move to another camera with no gap for the others.
const { cameras } = await group.devices();
await group.setCamera( true, { deviceId: cameras[ 1 ].id } );import { connect } from '@wordplus/realtime';
const rt = await connect();
await group.setMicrophone( false ); // muted
await group.setCamera( false ); // stopped, and the light goes off
const shared = await group.setScreenShare( true ); // false if they picked nothing
// Move to another camera with no gap for the others.
const { cameras } = await group.devices();
await group.setCamera( true, { deviceId: cameras[ 1 ].id } );const rt = window.Echo.connector.rt; // the connection Echo made
await group.setMicrophone( false ); // muted
await group.setCamera( false ); // stopped, and the light goes off
const shared = await group.setScreenShare( true ); // false if they picked nothing
// Move to another camera with no gap for the others.
const { cameras } = await group.devices();
await group.setCamera( true, { deviceId: cameras[ 1 ].id } );// In the component that holds the meeting, on the same useGroupCall().
const { camera, microphone, screen, setCamera, setMicrophone, setScreenShare } = useGroupCall( 'meeting:7', () => meetingToken( 7 ) );
return (
<>
<button onClick={ () => setMicrophone( ! microphone ) }>Microphone</button>
<button onClick={ () => setCamera( ! camera ) }>Camera</button>
<button onClick={ () => setScreenShare( ! screen ) }>Share screen</button>
</>
);<script setup>
// In the component that holds the meeting, on the same useGroupCall().
const { camera, microphone, screen, setCamera, setMicrophone, setScreenShare } = useGroupCall( 'meeting:7', () => meetingToken( 7 ) );
</script>
<template>
<button @click="setMicrophone( ! microphone )">Microphone</button>
<button @click="setCamera( ! camera )">Camera</button>
<button @click="setScreenShare( ! screen )">Share screen</button>
</template><!-- In the component that holds the meeting, on the same useGroupCall(). -->
<button onclick={ () => meeting.setMicrophone( ! meeting.microphone ) }>Microphone</button>
<button onclick={ () => meeting.setCamera( ! meeting.camera ) }>Camera</button>
<button onclick={ () => meeting.setScreenShare( ! meeting.screen ) }>Share screen</button>import { Component, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
// realtime.ts, one connection for the whole app:
// export const realtime = connect();
import { realtime } from './realtime';
@Component( {
selector: 'app-controls',
schemas: [ CUSTOM_ELEMENTS_SCHEMA ],
template: `<!-- Your buttons here -->`,
} )
export class ControlsComponent {
async ngOnInit() {
const rt = await realtime;
await group.setMicrophone( false ); // muted
await group.setCamera( false ); // stopped, and the light goes off
const shared = await group.setScreenShare( true ); // false if they picked nothing
// Move to another camera with no gap for the others.
const { cameras } = await group.devices();
await group.setCamera( true, { deviceId: cameras[ 1 ].id } );
}
}group.setMicrophone(false) // muted
group.setCamera(false) // stops sending the camera
group.flipCamera() // the front one to the back, and back
// Puts up the system's picker, in an app built with the broadcast extension.
await group.setScreenShare(true)group.setMicrophone(false) // muted
group.setCamera(false) // stops sending the camera
group.flipCamera() // the front one to the back, and back
// answer is what the system's dialog gave: ScreenShare.permissionIntent(activity).
group.setScreenShare(true, answer.data)// In the component that holds the meeting, on the same useGroupCall().
const { group, state } = useGroupCall( 'meeting:7', () => rt.tokenFrom( API + '/meeting-token', { id: 7 } ) );
// Sharing the phone's screen isn't in React Native yet.
return (
<>
<Button title="Microphone" onPress={ () => group?.setMicrophone( ! state.microphone ) } />
<Button title="Camera" onPress={ () => group?.setCamera( ! state.camera ) } />
<Button title="Flip camera" onPress={ () => group?.flipCamera() } />
</>
);await group.setMicrophone(false); // muted
await group.setCamera(false); // stops sending the camera
await group.flipCamera(); // the front one to the back, and back
// Android asks with the system's dialog, iOS needs the broadcast extension.
final shared = await group.setScreenShare(true); // false if they said noRelatori e ascoltatori
Una lezione, un panel o una stanza audio: pochi parlano e gli altri ascoltano. La tua route decide gli ascoltatori, e il tuo server ne fa parlare uno mentre la chiamata è in corso, conservando la scelta dove la route la legge per chi entra dopo.
// Your route, as in the first step, for /api/class-token?id=7.
const teacher = await isTeacherOf( id, me );
if ( ! teacher && ! await isStudentOf( id, me ) ) return refuse();
const token = await realtime.groupCallToken( me, 'class:' + id, {
type: 'audio',
admin: teacher,
publish: teacher || await maySpeak( id, me ), // a student listens until let speak
} );// The teacher's Let speak button, in a route that checks it is the teacher.
await setMaySpeak( 7, 34, true ); // where your route reads it
await realtime.call( 'class:7' ).letSpeak( 34 ); // and at once in the call// Your route, as in the first step, for /api/class-token?id=7.
const teacher = await isTeacherOf( id, me );
if ( ! teacher && ! await isStudentOf( id, me ) ) return refuse();
const token = await realtime.groupCallToken( me, 'class:' + id, {
type: 'audio',
admin: teacher,
publish: teacher || await maySpeak( id, me ), // a student listens until let speak
} );
// The teacher's Let speak button, in a route that checks it is the teacher.
await setMaySpeak( 7, 34, true ); // where your route reads it
await realtime.call( 'class:7' ).letSpeak( 34 ); // and at once in the call// Your route, as in the first step, for /api/class-token?id=7.
const teacher = await isTeacherOf( id, me );
if ( ! teacher && ! await isStudentOf( id, me ) ) return refuse();
const token = await realtime.groupCallToken( me, 'class:' + id, {
type: 'audio',
admin: teacher,
publish: teacher || await maySpeak( id, me ), // a student listens until let speak
} );
// The teacher's Let speak button, in a route that checks it is the teacher.
await setMaySpeak( 7, 34, true ); // where your route reads it
await realtime.call( 'class:7' ).letSpeak( 34 ); // and at once in the call// Your route, as in the first step, for /api/class-token?id=7.
$teacher = is_teacher_of( $id, $me );
abort_unless( $teacher || is_student_of( $id, $me ), 403 );
$token = Realtime::groupCallToken( $me, 'class:' . $id, [
'type' => 'audio',
'admin' => $teacher,
'publish' => $teacher || may_speak( $id, $me ), // a student listens until let speak
] );// The teacher's Let speak button, in a route that checks it is the teacher.
set_may_speak( 7, 34, true ); // where your route reads it
Realtime::call( 'class:7' )->letSpeak( 34 ); // and at once in the call// Your route, as in the first step, for /class-token.php?id=7.
$teacher = is_teacher_of( $id, $me );
if ( ! $teacher && ! is_student_of( $id, $me ) ) {
http_response_code( 403 );
exit;
}
$token = $realtime->groupCallToken( $me, 'class:' . $id, [
'type' => 'audio',
'admin' => $teacher,
'publish' => $teacher || may_speak( $id, $me ), // a student listens until let speak
] );// The teacher's Let speak button, in a route that checks it is the teacher.
set_may_speak( 7, 34, true ); // where your route reads it
$realtime->call( 'class:7' )->letSpeak( 34 ); // and at once in the call# Your route, as in the first step, for /api/class-token?id=7.
teacher = is_teacher_of(id, me)
if not teacher and not is_student_of(id, me):
return refuse()
token = realtime.group_call_token(
me,
"class:" + id,
type="audio",
admin=teacher,
publish=teacher or may_speak(id, me), # a student listens until let speak
)
# The teacher's Let speak button, in a route that checks it is the teacher.
set_may_speak(7, 34, True) # where your route reads it
realtime.call("class:7").let_speak(34) # and at once in the call# Your route, as in the first step, for /api/class-token?id=7.
teacher = is_teacher_of(id, me)
if not teacher and not is_student_of(id, me):
return refuse()
token = realtime.group_call_token(
me,
"class:" + id,
type="audio",
admin=teacher,
publish=teacher or may_speak(id, me), # a student listens until let speak
)
# In a def route, as these calls block.
# The teacher's Let speak button, in a route that checks it is the teacher.
set_may_speak(7, 34, True) # where your route reads it
realtime.call("class:7").let_speak(34) # and at once in the call# Your route, as in the first step, for /api/class-token?id=7.
teacher = is_teacher_of(id, me)
if not teacher and not is_student_of(id, me):
return refuse()
token = realtime.group_call_token(
me,
"class:" + id,
type="audio",
admin=teacher,
publish=teacher or may_speak(id, me), # a student listens until let speak
)
# The teacher's Let speak button, in a route that checks it is the teacher.
set_may_speak(7, 34, True) # where your route reads it
realtime.call("class:7").let_speak(34) # and at once in the call// Your route, as in the first step, for /api/class-token?id=7.
teacher := isTeacherOf(id, me)
if !teacher && !isStudentOf(id, me) {
w.WriteHeader(403)
return
}
token := app.GroupCallToken(me, "class:"+id, wordplus.GroupPlace{
Kind: "audio",
Admin: teacher,
Listener: !teacher && !maySpeak(id, me), // a student listens until let speak
Info: profile(me),
})# The teacher's Let speak button, in a route that checks it is the teacher.
wordplus POST '/wordplus/realtime/calls/class%3A7/permit' '{"user":"34","publish":true}'Hook e componenti per qualsiasi app React, con uno qualsiasi dei server sopra.
import { connect } from '@wordplus/realtime';
const rt = await connect();
const answer = await fetch( '/api/class-token?id=7' );
const group = await rt.joinGroupCall( ( await answer.json() ).token );
// Let on, it speaks. Back to listening, the microphone closes by itself.
group.on( 'permissions', ( { publish } ) => {
if ( publish ) group.setMicrophone( true );
} );
// Everyone sees who may speak.
group.on( 'person', ( person ) => place( person, person.publish ? speakers : listeners ) );import { connect } from '@wordplus/realtime';
const rt = await connect();
const answer = await fetch( '/api/class-token?id=7' );
const group = await rt.joinGroupCall( ( await answer.json() ).token );
// Let on, it speaks. Back to listening, the microphone closes by itself.
group.on( 'permissions', ( { publish } ) => {
if ( publish ) group.setMicrophone( true );
} );
// Everyone sees who may speak.
group.on( 'person', ( person ) => place( person, person.publish ? speakers : listeners ) );import { connect } from '@wordplus/realtime';
const rt = await connect();
const answer = await fetch( '/api/class-token?id=7' );
const group = await rt.joinGroupCall( ( await answer.json() ).token );
// Let on, it speaks. Back to listening, the microphone closes by itself.
group.on( 'permissions', ( { publish } ) => {
if ( publish ) group.setMicrophone( true );
} );
// Everyone sees who may speak.
group.on( 'person', ( person ) => place( person, person.publish ? speakers : listeners ) );import { connect } from '@wordplus/realtime';
const rt = await connect();
const answer = await fetch( '/api/class-token?id=7' );
const group = await rt.joinGroupCall( ( await answer.json() ).token );
// Let on, it speaks. Back to listening, the microphone closes by itself.
group.on( 'permissions', ( { publish } ) => {
if ( publish ) group.setMicrophone( true );
} );
// Everyone sees who may speak.
group.on( 'person', ( person ) => place( person, person.publish ? speakers : listeners ) );import { connect } from '@wordplus/realtime';
const rt = await connect();
const answer = await fetch( '/api/class-token?id=7' );
const group = await rt.joinGroupCall( ( await answer.json() ).token );
// Let on, it speaks. Back to listening, the microphone closes by itself.
group.on( 'permissions', ( { publish } ) => {
if ( publish ) group.setMicrophone( true );
} );
// Everyone sees who may speak.
group.on( 'person', ( person ) => place( person, person.publish ? speakers : listeners ) );import { connect } from '@wordplus/realtime';
const rt = await connect();
const answer = await fetch( '/api/class-token?id=7' );
const group = await rt.joinGroupCall( ( await answer.json() ).token );
// Let on, it speaks. Back to listening, the microphone closes by itself.
group.on( 'permissions', ( { publish } ) => {
if ( publish ) group.setMicrophone( true );
} );
// Everyone sees who may speak.
group.on( 'person', ( person ) => place( person, person.publish ? speakers : listeners ) );import { connect } from '@wordplus/realtime';
const rt = await connect();
const answer = await fetch( '/api/class-token?id=7' );
const group = await rt.joinGroupCall( ( await answer.json() ).token );
// Let on, it speaks. Back to listening, the microphone closes by itself.
group.on( 'permissions', ( { publish } ) => {
if ( publish ) group.setMicrophone( true );
} );
// Everyone sees who may speak.
group.on( 'person', ( person ) => place( person, person.publish ? speakers : listeners ) );import { connect } from '@wordplus/realtime';
const rt = await connect();
const answer = await fetch( '/api/class-token?id=7' );
const group = await rt.joinGroupCall( ( await answer.json() ).token );
// Let on, it speaks. Back to listening, the microphone closes by itself.
group.on( 'permissions', ( { publish } ) => {
if ( publish ) group.setMicrophone( true );
} );
// Everyone sees who may speak.
group.on( 'person', ( person ) => place( person, person.publish ? speakers : listeners ) );import { connect } from '@wordplus/realtime';
const rt = await connect();
const answer = await fetch( '/api/class-token?id=7' );
const group = await rt.joinGroupCall( ( await answer.json() ).token );
// Let on, it speaks. Back to listening, the microphone closes by itself.
group.on( 'permissions', ( { publish } ) => {
if ( publish ) group.setMicrophone( true );
} );
// Everyone sees who may speak.
group.on( 'person', ( person ) => place( person, person.publish ? speakers : listeners ) );const rt = window.Echo.connector.rt; // the connection Echo made
const answer = await fetch( '/api/class-token?id=7' );
const group = await rt.joinGroupCall( ( await answer.json() ).token );
// Let on, it speaks. Back to listening, the microphone closes by itself.
group.on( 'permissions', ( { publish } ) => {
if ( publish ) group.setMicrophone( true );
} );
// Everyone sees who may speak.
group.on( 'person', ( person ) => place( person, person.publish ? speakers : listeners ) );'use client'; // in Next.js
import { useEffect } from 'react';
import { useGroupCall } from '@wordplus/realtime/react';
// Asks your server for a token: your route for the class.
const classToken = async () => ( await ( await fetch( '/api/class-token?id=7' ) ).json() ).token;
// Inside <RealtimeProvider>, once for the whole app.
export function ClassRoom() {
const { group, people } = useGroupCall( 'class:7', classToken );
// Let on, it speaks. Back to listening, the microphone closes by itself.
useEffect( () => {
const speak = ( { publish } ) => publish && group?.setMicrophone( true );
group?.on( 'permissions', speak );
return () => { group?.off( 'permissions', speak ); };
}, [ group ] );
return <People speakers={ people.filter( ( person ) => person.publish ) } />;
}<script setup>
import { computed, watch } from 'vue';
import { useGroupCall } from '@wordplus/realtime/vue';
// Asks your server for a token: your route for the class.
const classToken = async () => ( await ( await fetch( '/api/class-token?id=7' ) ).json() ).token;
// provideRealtime() once, in your root component.
const { group, people } = useGroupCall( 'class:7', classToken );
// Let on, it speaks. Back to listening, the microphone closes by itself.
watch( group, ( now ) => {
now?.on( 'permissions', ( { publish } ) => publish && now.setMicrophone( true ) );
} );
const speakers = computed( () => people.value.filter( ( person ) => person.publish ) );
</script>
<template>
<People :speakers="speakers" />
</template><script>
import { useGroupCall } from '@wordplus/realtime/svelte';
// Asks your server for a token: your route for the class.
const classToken = async () => ( await ( await fetch( '/api/class-token?id=7' ) ).json() ).token;
// provideRealtime() once, in your root component.
const room = useGroupCall( 'class:7', classToken );
// Let on, it speaks. Back to listening, the microphone closes by itself.
$effect( () => {
room.group?.on( 'permissions', ( { publish } ) => publish && room.group.setMicrophone( true ) );
} );
</script>
<People speakers={ room.people.filter( ( person ) => person.publish ) } />import { Component, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
// realtime.ts, one connection for the whole app:
// export const realtime = connect();
import { realtime } from './realtime';
@Component( {
selector: 'app-class-room',
schemas: [ CUSTOM_ELEMENTS_SCHEMA ],
template: `<!-- Your list here -->`,
} )
export class ClassRoomComponent {
async ngOnInit() {
const rt = await realtime;
const answer = await fetch( '/api/class-token?id=7' );
const group = await rt.joinGroupCall( ( await answer.json() ).token );
// Let on, it speaks. Back to listening, the microphone closes by itself.
group.on( 'permissions', ( { publish } ) => {
if ( publish ) group.setMicrophone( true );
} );
// Everyone sees who may speak.
group.on( 'person', ( person ) => place( person, person.publish ? speakers : listeners ) );
}
}let token = try await api.classToken(id: 7) // your own request to your route
let group = try await rt.joinGroupCall(token)
// Let on, it speaks. Back to listening, the media server took it down already.
group.onPermissions { can in
group.microphone = can.publish
}
let speakers = group.people.filter(\.publish)val token = api.classToken(id = 7) // your own request to your route
val group = rt.joinGroupCall(context, token)
// Let on, it speaks. Back to listening, the media server took it down already.
group.onPermissions { can ->
group.microphone = can.publish
}
val speakers = group.people.filter { it.publish }import { useEffect, useRef } from 'react';
import { useGroupCall, useRealtime } from '@wordplus/realtime-react-native';
const API = 'https://app.example.com/api'; // your server, in full
// Inside <RealtimeProvider>, once for the whole app.
export function ClassRoom() {
const rt = useRealtime();
const { group, state } = useGroupCall( 'class:7', () => rt.tokenFrom( API + '/class-token', { id: 7 } ) );
const letOn = state?.self?.publish;
const before = useRef( letOn );
// Let on, it speaks. Back to listening, the microphone closes by itself.
useEffect( () => {
if ( letOn && before.current === false ) group.setMicrophone( true );
before.current = letOn;
}, [ group, letOn ] );
return <People speakers={ state?.people.filter( ( person ) => person.publish ) } />;
}final token = await rt.tokenFrom('$api/class-token', {'id': 7});
final group = await rt.joinGroupCall(token);
// Let on, it speaks. Back to listening, the media server took it down already.
group.onPermissions((can) {
if (can.publish) group.setMicrophone(true);
});
final speakers = group.people.where((person) => person.publish);Silenzia e rimuovi persone
Lo fa l’host dalla pagina, come gli consente il suo token. La schermata di chiamata ha queste azioni su ogni riquadro.
Hook e componenti per qualsiasi app React, con uno qualsiasi dei server sopra.
import { connect } from '@wordplus/realtime';
const rt = await connect();
// For the one your token made the host. Anyone else is refused forbidden.
if ( group.can.admin ) {
await group.mute( 34 ); // their microphone off, which they may turn on again
await group.makeListener( 34 ); // sends nothing, until let speak
await group.letSpeak( 34 );
await group.remove( 34 ); // out of the call
}import { connect } from '@wordplus/realtime';
const rt = await connect();
// For the one your token made the host. Anyone else is refused forbidden.
if ( group.can.admin ) {
await group.mute( 34 ); // their microphone off, which they may turn on again
await group.makeListener( 34 ); // sends nothing, until let speak
await group.letSpeak( 34 );
await group.remove( 34 ); // out of the call
}import { connect } from '@wordplus/realtime';
const rt = await connect();
// For the one your token made the host. Anyone else is refused forbidden.
if ( group.can.admin ) {
await group.mute( 34 ); // their microphone off, which they may turn on again
await group.makeListener( 34 ); // sends nothing, until let speak
await group.letSpeak( 34 );
await group.remove( 34 ); // out of the call
}import { connect } from '@wordplus/realtime';
const rt = await connect();
// For the one your token made the host. Anyone else is refused forbidden.
if ( group.can.admin ) {
await group.mute( 34 ); // their microphone off, which they may turn on again
await group.makeListener( 34 ); // sends nothing, until let speak
await group.letSpeak( 34 );
await group.remove( 34 ); // out of the call
}import { connect } from '@wordplus/realtime';
const rt = await connect();
// For the one your token made the host. Anyone else is refused forbidden.
if ( group.can.admin ) {
await group.mute( 34 ); // their microphone off, which they may turn on again
await group.makeListener( 34 ); // sends nothing, until let speak
await group.letSpeak( 34 );
await group.remove( 34 ); // out of the call
}import { connect } from '@wordplus/realtime';
const rt = await connect();
// For the one your token made the host. Anyone else is refused forbidden.
if ( group.can.admin ) {
await group.mute( 34 ); // their microphone off, which they may turn on again
await group.makeListener( 34 ); // sends nothing, until let speak
await group.letSpeak( 34 );
await group.remove( 34 ); // out of the call
}import { connect } from '@wordplus/realtime';
const rt = await connect();
// For the one your token made the host. Anyone else is refused forbidden.
if ( group.can.admin ) {
await group.mute( 34 ); // their microphone off, which they may turn on again
await group.makeListener( 34 ); // sends nothing, until let speak
await group.letSpeak( 34 );
await group.remove( 34 ); // out of the call
}import { connect } from '@wordplus/realtime';
const rt = await connect();
// For the one your token made the host. Anyone else is refused forbidden.
if ( group.can.admin ) {
await group.mute( 34 ); // their microphone off, which they may turn on again
await group.makeListener( 34 ); // sends nothing, until let speak
await group.letSpeak( 34 );
await group.remove( 34 ); // out of the call
}import { connect } from '@wordplus/realtime';
const rt = await connect();
// For the one your token made the host. Anyone else is refused forbidden.
if ( group.can.admin ) {
await group.mute( 34 ); // their microphone off, which they may turn on again
await group.makeListener( 34 ); // sends nothing, until let speak
await group.letSpeak( 34 );
await group.remove( 34 ); // out of the call
}const rt = window.Echo.connector.rt; // the connection Echo made
// For the one your token made the host. Anyone else is refused forbidden.
if ( group.can.admin ) {
await group.mute( 34 ); // their microphone off, which they may turn on again
await group.makeListener( 34 ); // sends nothing, until let speak
await group.letSpeak( 34 );
await group.remove( 34 ); // out of the call
}// In the component that holds the meeting, on the same useGroupCall().
const { group } = useGroupCall( 'meeting:7', () => meetingToken( 7 ) );
// For the one your token made the host. Anyone else is refused forbidden.
if ( group?.can.admin ) {
return (
<>
<button onClick={ () => group.mute( 34 ) }>Mute</button>
<button onClick={ () => group.makeListener( 34 ) }>Make a listener</button>
<button onClick={ () => group.remove( 34 ) }>Remove</button>
</>
);
}<script setup>
// In the component that holds the meeting, on the same useGroupCall().
const { group } = useGroupCall( 'meeting:7', () => meetingToken( 7 ) );
</script>
<template>
<!-- For the one your token made the host. Anyone else is refused forbidden. -->
<template v-if="group?.can.admin">
<button @click="group.mute( 34 )">Mute</button>
<button @click="group.makeListener( 34 )">Make a listener</button>
<button @click="group.remove( 34 )">Remove</button>
</template>
</template><!-- In the component that holds the meeting, on the same useGroupCall(). -->
<!-- For the one your token made the host. Anyone else is refused forbidden. -->
{#if meeting.group?.can.admin}
<button onclick={ () => meeting.group.mute( 34 ) }>Mute</button>
<button onclick={ () => meeting.group.makeListener( 34 ) }>Make a listener</button>
<button onclick={ () => meeting.group.remove( 34 ) }>Remove</button>
{/if}import { Component, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
// realtime.ts, one connection for the whole app:
// export const realtime = connect();
import { realtime } from './realtime';
@Component( {
selector: 'app-host',
schemas: [ CUSTOM_ELEMENTS_SCHEMA ],
template: `<!-- Your buttons here -->`,
} )
export class HostComponent {
async ngOnInit() {
const rt = await realtime;
// Asks your server for a token: your route from the first step.
async function meetingToken( id ) {
const answer = await fetch( '/api/meeting-token?id=' + id );
if ( ! answer.ok ) throw new Error( 'Your server said no' );
return ( await answer.json() ).token;
}
const group = await rt.joinGroupCall( await meetingToken( 7 ) );
// For the one your token made the host. Anyone else is refused forbidden.
if ( group.can.admin ) {
await group.mute( 34 ); // their microphone off, which they may turn on again
await group.makeListener( 34 ); // sends nothing, until let speak
await group.letSpeak( 34 );
await group.remove( 34 ); // out of the call
}
}
}// For the one your token made the host. Anyone else is refused forbidden.
if group.can.admin {
try await group.mute("34") // their microphone off, which they may turn on again
try await group.makeListener("34") // sends nothing, until let speak
try await group.letSpeak("34")
try await group.remove("34") // out of the call
}// For the one your token made the host. Anyone else is refused forbidden.
if (group.can.admin) {
group.mute("34") // their microphone off, which they may turn on again
group.makeListener("34") // sends nothing, until let speak
group.letSpeak("34")
group.remove("34") // out of the call
}// In the component that holds the meeting, on the same useGroupCall().
const { group, state } = useGroupCall( 'meeting:7', () => rt.tokenFrom( API + '/meeting-token', { id: 7 } ) );
// For the one your token made the host. Anyone else is refused forbidden.
if ( state?.can.admin ) {
return (
<>
<Button title="Mute" onPress={ () => group.mute( '34' ) } />
<Button title="Make a listener" onPress={ () => group.makeListener( '34' ) } />
<Button title="Let speak" onPress={ () => group.letSpeak( '34' ) } />
<Button title="Remove" onPress={ () => group.remove( '34' ) } />
</>
);
}// For the one your token made the host. Anyone else is refused forbidden.
if (group.can.admin) {
await group.mute('34'); // their microphone off, which they may turn on again
await group.makeListener('34'); // sends nothing, until let speak
await group.letSpeak('34');
await group.remove('34'); // out of the call
}Metti in evidenza qualcuno
Mette qualcuno nei riquadri principali per tutti, fino a quattro persone, anche l’host.
Hook e componenti per qualsiasi app React, con uno qualsiasi dei server sopra.
import { connect } from '@wordplus/realtime';
const rt = await connect();
// On the main tiles for everyone, up to four people.
await group.spotlightOn( 34 );
group.on( 'spotlit', ( users ) => redraw( users ) );
await group.spotlightOff( 34 ); // or spotlightOff() for everyoneimport { connect } from '@wordplus/realtime';
const rt = await connect();
// On the main tiles for everyone, up to four people.
await group.spotlightOn( 34 );
group.on( 'spotlit', ( users ) => redraw( users ) );
await group.spotlightOff( 34 ); // or spotlightOff() for everyoneimport { connect } from '@wordplus/realtime';
const rt = await connect();
// On the main tiles for everyone, up to four people.
await group.spotlightOn( 34 );
group.on( 'spotlit', ( users ) => redraw( users ) );
await group.spotlightOff( 34 ); // or spotlightOff() for everyoneimport { connect } from '@wordplus/realtime';
const rt = await connect();
// On the main tiles for everyone, up to four people.
await group.spotlightOn( 34 );
group.on( 'spotlit', ( users ) => redraw( users ) );
await group.spotlightOff( 34 ); // or spotlightOff() for everyoneimport { connect } from '@wordplus/realtime';
const rt = await connect();
// On the main tiles for everyone, up to four people.
await group.spotlightOn( 34 );
group.on( 'spotlit', ( users ) => redraw( users ) );
await group.spotlightOff( 34 ); // or spotlightOff() for everyoneimport { connect } from '@wordplus/realtime';
const rt = await connect();
// On the main tiles for everyone, up to four people.
await group.spotlightOn( 34 );
group.on( 'spotlit', ( users ) => redraw( users ) );
await group.spotlightOff( 34 ); // or spotlightOff() for everyoneimport { connect } from '@wordplus/realtime';
const rt = await connect();
// On the main tiles for everyone, up to four people.
await group.spotlightOn( 34 );
group.on( 'spotlit', ( users ) => redraw( users ) );
await group.spotlightOff( 34 ); // or spotlightOff() for everyoneimport { connect } from '@wordplus/realtime';
const rt = await connect();
// On the main tiles for everyone, up to four people.
await group.spotlightOn( 34 );
group.on( 'spotlit', ( users ) => redraw( users ) );
await group.spotlightOff( 34 ); // or spotlightOff() for everyoneimport { connect } from '@wordplus/realtime';
const rt = await connect();
// On the main tiles for everyone, up to four people.
await group.spotlightOn( 34 );
group.on( 'spotlit', ( users ) => redraw( users ) );
await group.spotlightOff( 34 ); // or spotlightOff() for everyoneconst rt = window.Echo.connector.rt; // the connection Echo made
// On the main tiles for everyone, up to four people.
await group.spotlightOn( 34 );
group.on( 'spotlit', ( users ) => redraw( users ) );
await group.spotlightOff( 34 ); // or spotlightOff() for everyone// In the component that holds the meeting, on the same useGroupCall().
const { group } = useGroupCall( 'meeting:7', () => meetingToken( 7 ) );
// On the main tiles for everyone, up to four people. group.spotlit names them.
return (
<>
<button onClick={ () => group?.spotlightOn( 34 ) }>Spotlight</button>
<button onClick={ () => group?.spotlightOff( 34 ) }>Remove spotlight</button>
</>
);<script setup>
// In the component that holds the meeting, on the same useGroupCall().
const { group } = useGroupCall( 'meeting:7', () => meetingToken( 7 ) );
</script>
<template>
<!-- On the main tiles for everyone, up to four people. group.spotlit names them. -->
<button @click="group?.spotlightOn( 34 )">Spotlight</button>
<button @click="group?.spotlightOff( 34 )">Remove spotlight</button>
</template><!-- In the component that holds the meeting, on the same useGroupCall(). -->
<!-- On the main tiles for everyone, up to four people. group.spotlit names them. -->
<button onclick={ () => meeting.group?.spotlightOn( 34 ) }>Spotlight</button>
<button onclick={ () => meeting.group?.spotlightOff( 34 ) }>Remove spotlight</button>import { Component, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
// realtime.ts, one connection for the whole app:
// export const realtime = connect();
import { realtime } from './realtime';
@Component( {
selector: 'app-spotlight',
schemas: [ CUSTOM_ELEMENTS_SCHEMA ],
template: `<!-- Your buttons here -->`,
} )
export class SpotlightComponent {
async ngOnInit() {
const rt = await realtime;
// Asks your server for a token: your route from the first step.
async function meetingToken( id ) {
const answer = await fetch( '/api/meeting-token?id=' + id );
if ( ! answer.ok ) throw new Error( 'Your server said no' );
return ( await answer.json() ).token;
}
const group = await rt.joinGroupCall( await meetingToken( 7 ) );
// On the main tiles for everyone, up to four people.
await group.spotlightOn( 34 );
group.on( 'spotlit', ( users ) => redraw( users ) );
await group.spotlightOff( 34 ); // or spotlightOff() for everyone
}
}// On the main tiles for everyone, up to four people.
try await group.spotlightOn("34")
group.onSpotlit { users in redraw(users) }
try await group.spotlightOff("34") // or spotlightOff() for everyone// On the main tiles for everyone, up to four people.
group.spotlightOn("34")
group.onSpotlit { users -> redraw(users) }
group.spotlightOff("34") // or spotlightOff() for everyone// In the component that holds the meeting, on the same useGroupCall().
const { group, state } = useGroupCall( 'meeting:7', () => rt.tokenFrom( API + '/meeting-token', { id: 7 } ) );
// On the main tiles for everyone, up to four people. state.spotlit names them.
return (
<>
<Button title="Spotlight" onPress={ () => group?.spotlightOn( '34' ) } />
<Button title="Remove spotlight" onPress={ () => group?.spotlightOff( '34' ) } />
</>
);// On the main tiles for everyone, up to four people.
await group.spotlightOn('34');
group.onSpotlit((users) => redraw(users));
await group.spotlightOff('34'); // or spotlightOff() for everyoneGestiscila dal tuo server
Vedi chi c’è in una chiamata e silenzia, rendi ascoltatore o rimuovi chiunque, senza nessuna pagina aperta. Chi viene rimosso resta fuori finché il tuo server non gli firma un nuovo token.
// No page needs to be open. Check who asks, in your own route.
const call = realtime.call( 'meeting:7' );
await call.get(); // { people, started_at, list: [ { user, camera, microphone, screen } ] }
await call.mute( 34 ); // or mute( 34, 'camera' ), mute( 34, 'screen' )
await call.makeListener( 34 ); // sends nothing, until letSpeak( 34 )
await call.remove( 34 ); // out now
await realtime.listCalls(); // every group call going on: [ { name, people, started_at } ]// No page needs to be open. Check who asks, in your own route.
const call = realtime.call( 'meeting:7' );
await call.get(); // { people, started_at, list: [ { user, camera, microphone, screen } ] }
await call.mute( 34 ); // or mute( 34, 'camera' ), mute( 34, 'screen' )
await call.makeListener( 34 ); // sends nothing, until letSpeak( 34 )
await call.remove( 34 ); // out now
await realtime.listCalls(); // every group call going on: [ { name, people, started_at } ]// No page needs to be open. Check who asks, in your own route.
const call = realtime.call( 'meeting:7' );
await call.get(); // { people, started_at, list: [ { user, camera, microphone, screen } ] }
await call.mute( 34 ); // or mute( 34, 'camera' ), mute( 34, 'screen' )
await call.makeListener( 34 ); // sends nothing, until letSpeak( 34 )
await call.remove( 34 ); // out now
await realtime.listCalls(); // every group call going on: [ { name, people, started_at } ]// No page needs to be open. Check who asks, in your own route.
$call = Realtime::call( 'meeting:7' );
$call->get(); // [ 'people', 'started_at', 'list' => [ [ 'user', 'camera', 'microphone', 'screen' ] ] ]
$call->mute( 34 ); // or mute( 34, 'camera' ), mute( 34, 'screen' )
$call->makeListener( 34 ); // sends nothing, until letSpeak( 34 )
$call->remove( 34 ); // out now
Realtime::listCalls(); // every group call going on// No page needs to be open. Check who asks, in your own route.
$call = $realtime->call( 'meeting:7' );
$call->get(); // [ 'people', 'started_at', 'list' => [ [ 'user', 'camera', 'microphone', 'screen' ] ] ]
$call->mute( 34 ); // or mute( 34, 'camera' ), mute( 34, 'screen' )
$call->makeListener( 34 ); // sends nothing, until letSpeak( 34 )
$call->remove( 34 ); // out now
$realtime->listCalls(); // every group call going on# No page needs to be open. Check who asks, in your own route.
call = realtime.call("meeting:7")
call.get() # {"people", "started_at", "list": [{"user", "camera", "microphone", "screen"}]}
call.mute(34) # or mute(34, "camera"), mute(34, "screen")
call.make_listener(34) # sends nothing, until let_speak(34)
call.remove(34) # out now
realtime.list_calls() # every group call going on# In a def route, as these calls block.
# No page needs to be open. Check who asks, in your own route.
call = realtime.call("meeting:7")
call.get() # {"people", "started_at", "list": [{"user", "camera", "microphone", "screen"}]}
call.mute(34) # or mute(34, "camera"), mute(34, "screen")
call.make_listener(34) # sends nothing, until let_speak(34)
call.remove(34) # out now
realtime.list_calls() # every group call going on# No page needs to be open. Check who asks, in your own route.
call = realtime.call("meeting:7")
call.get() # {"people", "started_at", "list": [{"user", "camera", "microphone", "screen"}]}
call.mute(34) # or mute(34, "camera"), mute(34, "screen")
call.make_listener(34) # sends nothing, until let_speak(34)
call.remove(34) # out now
realtime.list_calls() # every group call going on# No page needs to be open. Check who asks, in your own route.
wordplus GET '/wordplus/realtime/calls/meeting%3A7'
wordplus POST '/wordplus/realtime/calls/meeting%3A7/mute' '{"user":"34","track":"microphone"}'
wordplus POST '/wordplus/realtime/calls/meeting%3A7/permit' '{"user":"34","publish":false}'
wordplus POST '/wordplus/realtime/calls/meeting%3A7/remove' '{"user":"34"}'
# Every group call going on.
wordplus GET '/wordplus/realtime/calls'Terminala per tutti
Rimuove tutti in una volta. Usa di nuovo il nome e ne comincia una nuova.
// Everyone out, and the tokens signed before don't open it again.
await realtime.call( 'meeting:7' ).end();// Everyone out, and the tokens signed before don't open it again.
await realtime.call( 'meeting:7' ).end();// Everyone out, and the tokens signed before don't open it again.
await realtime.call( 'meeting:7' ).end();// Everyone out, and the tokens signed before don't open it again.
Realtime::call( 'meeting:7' )->end();// Everyone out, and the tokens signed before don't open it again.
$realtime->call( 'meeting:7' )->end();# Everyone out, and the tokens signed before don't open it again.
realtime.call("meeting:7").end()# In a def route, as these calls block.
# Everyone out, and the tokens signed before don't open it again.
realtime.call("meeting:7").end()# Everyone out, and the tokens signed before don't open it again.
realtime.call("meeting:7").end()# Everyone out, and the tokens signed before don't open it again.
wordplus POST '/wordplus/realtime/calls/meeting%3A7/end'Cifrala end-to-end
Una parola nel tuo token. I nostri media server passano allora fotogrammi che non possono leggere, e un browser che non può cifrare viene rifiutato anziché inviare in chiaro.
// In your route. Frames are encrypted in each browser, with a key your server makes.
const token = await realtime.groupCallToken( me, 'meeting:' + id, { encrypt: true } );// In your route. Frames are encrypted in each browser, with a key your server makes.
const token = await realtime.groupCallToken( me, 'meeting:' + id, { encrypt: true } );// In your route. Frames are encrypted in each browser, with a key your server makes.
const token = await realtime.groupCallToken( me, 'meeting:' + id, { encrypt: true } );// In your route. Frames are encrypted in each browser, with a key your server makes.
$token = Realtime::groupCallToken( $me, 'meeting:' . $id, [ 'encrypt' => true ] );// In your route. Frames are encrypted in each browser, with a key your server makes.
$token = $realtime->groupCallToken( $me, 'meeting:' . $id, [ 'encrypt' => true ] );# In your route. Frames are encrypted in each browser, with a key your server makes.
token = realtime.group_call_token(me, "meeting:" + id, encrypt=True)# In your route. Frames are encrypted in each browser, with a key your server makes.
token = realtime.group_call_token(me, "meeting:" + id, encrypt=True)# In your route. Frames are encrypted in each browser, with a key your server makes.
token = realtime.group_call_token(me, "meeting:" + id, encrypt=True)// In your route. Frames are encrypted in each browser, with a key your server makes.
token := app.GroupCallToken(me, "meeting:"+id, wordplus.GroupPlace{Encrypt: true, Info: profile(me)})Hook e componenti per qualsiasi app React, con uno qualsiasi dei server sopra.
import { connect } from '@wordplus/realtime';
const rt = await connect();
// Asks your server for a token: your route from the first step.
async function meetingToken( id ) {
const answer = await fetch( '/api/meeting-token?id=' + id );
if ( ! answer.ok ) throw new Error( 'Your server said no' );
return ( await answer.json() ).token;
}
const group = await rt.joinGroupCall( await meetingToken( 7 ) );
if ( group.encrypted ) showLock();import { connect } from '@wordplus/realtime';
const rt = await connect();
// Asks your server for a token: your route from the first step.
async function meetingToken( id ) {
const answer = await fetch( '/api/meeting-token?id=' + id );
if ( ! answer.ok ) throw new Error( 'Your server said no' );
return ( await answer.json() ).token;
}
const group = await rt.joinGroupCall( await meetingToken( 7 ) );
if ( group.encrypted ) showLock();import { connect } from '@wordplus/realtime';
const rt = await connect();
// Asks your server for a token: your route from the first step.
async function meetingToken( id ) {
const answer = await fetch( '/api/meeting-token?id=' + id );
if ( ! answer.ok ) throw new Error( 'Your server said no' );
return ( await answer.json() ).token;
}
const group = await rt.joinGroupCall( await meetingToken( 7 ) );
if ( group.encrypted ) showLock();import { connect } from '@wordplus/realtime';
const rt = await connect();
// Asks your server for a token: your route from the first step.
async function meetingToken( id ) {
const answer = await fetch( '/api/meeting-token?id=' + id );
if ( ! answer.ok ) throw new Error( 'Your server said no' );
return ( await answer.json() ).token;
}
const group = await rt.joinGroupCall( await meetingToken( 7 ) );
if ( group.encrypted ) showLock();import { connect } from '@wordplus/realtime';
const rt = await connect();
// Asks your server for a token: your route from the first step.
async function meetingToken( id ) {
const answer = await fetch( '/api/meeting-token?id=' + id );
if ( ! answer.ok ) throw new Error( 'Your server said no' );
return ( await answer.json() ).token;
}
const group = await rt.joinGroupCall( await meetingToken( 7 ) );
if ( group.encrypted ) showLock();import { connect } from '@wordplus/realtime';
const rt = await connect();
// Asks your server for a token: your route from the first step.
async function meetingToken( id ) {
const answer = await fetch( '/api/meeting-token?id=' + id );
if ( ! answer.ok ) throw new Error( 'Your server said no' );
return ( await answer.json() ).token;
}
const group = await rt.joinGroupCall( await meetingToken( 7 ) );
if ( group.encrypted ) showLock();import { connect } from '@wordplus/realtime';
const rt = await connect();
// Asks your server for a token: your route from the first step.
async function meetingToken( id ) {
const answer = await fetch( '/api/meeting-token?id=' + id );
if ( ! answer.ok ) throw new Error( 'Your server said no' );
return ( await answer.json() ).token;
}
const group = await rt.joinGroupCall( await meetingToken( 7 ) );
if ( group.encrypted ) showLock();import { connect } from '@wordplus/realtime';
const rt = await connect();
// Asks your server for a token: your route from the first step.
async function meetingToken( id ) {
const answer = await fetch( '/api/meeting-token?id=' + id );
if ( ! answer.ok ) throw new Error( 'Your server said no' );
return ( await answer.json() ).token;
}
const group = await rt.joinGroupCall( await meetingToken( 7 ) );
if ( group.encrypted ) showLock();import { connect } from '@wordplus/realtime';
const rt = await connect();
// Asks your server for a token: your route from the first step.
async function meetingToken( id ) {
const answer = await fetch( '/api/meeting-token?id=' + id );
if ( ! answer.ok ) throw new Error( 'Your server said no' );
return ( await answer.json() ).token;
}
const group = await rt.joinGroupCall( await meetingToken( 7 ) );
if ( group.encrypted ) showLock();const rt = window.Echo.connector.rt; // the connection Echo made
// Asks your server for a token: your route from the first step.
async function meetingToken( id ) {
const answer = await fetch( '/api/meeting-token?id=' + id );
if ( ! answer.ok ) throw new Error( 'Your server said no' );
return ( await answer.json() ).token;
}
const group = await rt.joinGroupCall( await meetingToken( 7 ) );
if ( group.encrypted ) showLock();// In the component that holds the meeting, on the same useGroupCall().
const { group } = useGroupCall( 'meeting:7', () => meetingToken( 7 ) );
return group?.encrypted ? <Lock /> : null;<script setup>
// In the component that holds the meeting, on the same useGroupCall().
const { group } = useGroupCall( 'meeting:7', () => meetingToken( 7 ) );
</script>
<template>
<Lock v-if="group?.encrypted" />
</template><!-- In the component that holds the meeting, on the same useGroupCall(). -->
{#if meeting.group?.encrypted}
<Lock />
{/if}import { Component, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
// realtime.ts, one connection for the whole app:
// export const realtime = connect();
import { realtime } from './realtime';
@Component( {
selector: 'app-meeting',
schemas: [ CUSTOM_ELEMENTS_SCHEMA ],
template: `<!-- Your lock here -->`,
} )
export class MeetingComponent {
async ngOnInit() {
const rt = await realtime;
// Asks your server for a token: your route from the first step.
async function meetingToken( id ) {
const answer = await fetch( '/api/meeting-token?id=' + id );
if ( ! answer.ok ) throw new Error( 'Your server said no' );
return ( await answer.json() ).token;
}
const group = await rt.joinGroupCall( await meetingToken( 7 ) );
if ( group.encrypted ) showLock();
}
}let token = try await api.meetingToken(id: 7) // your own request to your route
let group = try await rt.joinGroupCall(token)
if group.encrypted { showLock() }val token = api.meetingToken(id = 7) // your own request to your route
val group = rt.joinGroupCall(context, token)
if (group.encrypted) showLock()// In the component that holds the meeting, on the same useGroupCall().
const { state } = useGroupCall( 'meeting:7', () => rt.tokenFrom( API + '/meeting-token', { id: 7 } ) );
return state?.encrypted ? <Lock /> : null;final token = await rt.tokenFrom('$api/meeting-token', {'id': 7});
final group = await rt.joinGroupCall(token);
if (group.encrypted) showLock();Fattura al minuto
Il tuo server sa quanto è rimasta ogni persona nella chiamata, conteggiato sui nostri server, così puoi fatturare ai tuoi utenti. L’evento può arrivare due volte, quindi addebita una sola volta per ogni id. charge è una funzione tua.
// Each person, for their own time in it, by the minute begun. Charge once for each id.
realtime.on( 'group.left', async ( { id, user, seconds } ) => {
if ( seconds ) await charge( id, user, Math.ceil( seconds / 60 ) );
} );// Each person, for their own time in it, by the minute begun. Charge once for each id.
realtime.on( 'group.left', async ( { id, user, seconds } ) => {
if ( seconds ) await charge( id, user, Math.ceil( seconds / 60 ) );
} );// Each person, for their own time in it, by the minute begun. Charge once for each id.
realtime.on( 'group.left', async ( { id, user, seconds } ) => {
if ( seconds ) await charge( id, user, Math.ceil( seconds / 60 ) );
} );$this->callAfterResolving( Realtime::class, function ( Realtime $realtime ) {
// Each person, for their own time in it, by the minute begun. Charge once for each id.
$realtime->on( 'group.left', function ( array $e ) {
if ( $e['seconds'] ) {
charge( $e['id'], $e['user'], (int) ceil( $e['seconds'] / 60 ) );
}
} );
} );// Each person, for their own time in it, by the minute begun. Charge once for each id.
$realtime->on( 'group.left', function ( array $e ) {
if ( $e['seconds'] ) {
charge( $e['id'], $e['user'], (int) ceil( $e['seconds'] / 60 ) );
}
} );# Each person, for their own time in it, by the minute begun. Charge once for each id.
def group_left(e):
if e["seconds"]:
charge(e["id"], e["user"], math.ceil(e["seconds"] / 60))
realtime.on("group.left", group_left)# Each person, for their own time in it, by the minute begun. Charge once for each id.
def group_left(e):
if e["seconds"]:
charge(e["id"], e["user"], math.ceil(e["seconds"] / 60))
realtime.on("group.left", group_left)# Each person, for their own time in it, by the minute begun. Charge once for each id.
def group_left(e):
if e["seconds"]:
charge(e["id"], e["user"], math.ceil(e["seconds"] / 60))
realtime.on("group.left", group_left)// In your webhook route, once its signature is checked as the docs say.
// Each person, for their own time in it, by the minute begun. Charge once for each id.
if event.Type == "group.left" && event.Seconds > 0 {
charge(event.ID, event.User, (event.Seconds+59)/60)
}Le chiamate in ogni stack, con tutta la configurazione:
Casi d’uso
Cosa si costruisce con le chiamate di gruppo
Ognuno è un’app completa nella documentazione, con il suo server in Node.js, PHP e Python.
Riunioni di team
Una riunione video per ogni team o evento, con condivisione dello schermo, che chi la conduce chiude per tutti.
Lezioni e stanze audio
Un docente o un panel parla e gli altri ascoltano, alzando la mano per parlare.
Watch party
Un video che parte, si ferma e salta per tutti insieme come fa chi ospita, con una chat accanto e una chiamata del gruppo.
Consulenze su appuntamento
Una visita in video con una medica, un avvocato, una tutor o un coach, aperta solo ai due prenotati, alla sua ora.
Sale d’attesa e stanze separate
Gli ospiti aspettano finché l’host non li fa entrare, e l’host manda le persone in stanze più piccole e poi le riporta indietro.
Addebitare le chiamate
Il tuo server sa quanto ha parlato ogni persona, conteggiato sui nostri server, per fatturare al minuto.
Prezzi
Prezzo per connessioni, mai per messaggi
Da $11.99 al mese per 1000 connessioni simultanee, con fatturazione annuale, o $14.99 con fatturazione mensile.
Chiamate di gruppo oltre il tuo piano: $0.20 ogni 1.000 minuti, $0.10 in audio.
Un solo prezzo a qualsiasi risoluzione. Banda, relay e messaggi non vengono mai addebitati, e le chiamate tra due persone sono incluse. Gestiamo in proprio relay e media server, ed è per questo che questi prezzi restano bassi.
Con 1.000 connessioni, le chiamate di gruppo sono senza conteggio fino a 32 persone in video contemporaneamente, e una persona in audio conta la metà, senza limite di persone per chiamata. Ogni 1.000 connessioni in più aggiungono 12 persone in video. Oltre, ogni persona in video in più consuma un credito al minuto, in audio la metà, e il tuo piano aggiunge 5000 crediti al mese ogni 1.000 connessioni.
Domande
Domande frequenti
Quante persone possono partecipare a una chiamata di gruppo?
Non c’è limite di persone per chiamata. Con 1.000 connessioni, fino a 32 persone in video contemporaneamente non consumano crediti, e una persona in audio conta la metà, e ogni 1.000 connessioni in più ne aggiungono 12. Oltre, ogni persona in video in più consuma un credito al minuto.
Mi servono media server miei?
No. Ogni persona in una chiamata di gruppo invia la sua fotocamera, il suo microfono e il suo schermo una volta sola, e i nostri media server li passano a tutti gli altri, in più regioni. Non hai niente da ospitare.
Chi decide chi entra e chi fa da host?
La tua app. Il tuo server dà un token a ogni persona, leggendo il tuo database, che dice chi entra, chi parla e chi ascolta soltanto, e chi fa da host. Il cloud applica ogni token, e il tuo server può revocare l’accesso in qualsiasi momento.
Le chiamate di gruppo sono cifrate?
Quando il tuo server lo dice, ogni fotogramma è cifrato nel browser con una chiave che solo il tuo server consegna, così i nostri media server passano ciò che non possono leggere.
Quali stack possono usare l’SDK per chiamate di gruppo?
Next.js ed Express, Laravel e PHP puro, Django, FastAPI e Flask, Capacitor, iOS e Android, ciascuno con una guida. Un server in qualsiasi altro linguaggio usa l’API HTTP. Le app Flutter hanno le chiamate su iOS e Android, e le app React Native per ora su iOS.
Posso costruire la mia schermata di riunione?
Sì. La schermata di chiamata è facoltativa. Cambia i suoi colori e testi, oppure disegna la riunione tu stesso con l’SDK, fino a ogni persona che ne fa parte.
Posso addebitare le chiamate di gruppo ai miei utenti?
Sì. WordPlus Cloud comunica al tuo server via webhook quando ogni persona è entrata e uscita, conteggiato sui suoi server, così la tua app può fatturare a ciascuna al minuto.
Domande sulla tua integrazione? Scrivici: ti aiutiamo con gli SDK, la schermata di chiamata e il tuo stack.