Presence・通信
参加中の状態、一時メッセージ、音声と画面共有。
PresenceChannel
set は自分の状態を全置換し、null で消去します。保持する icon も毎回渡します。get / watch はscope単位で、read / sendの資格が必要です。
TypeScript · シグネチャ
interface PresenceChannel {
get(scope: string): Promise<Read<Presence[]>>;
watch(scope: string, listener: (value: Read<Presence[]>) => void, options?: WatchOptions): Promise<() => void>;
set(value: { placement: Placement; selection: string[]; icon?: string } | null): Promise<Presence | null>;
}Messaging
保存しない一時配送です。watch は新着だけで初期値・履歴はありません。send の成功はNodeの受付までです。
TypeScript · シグネチャ
interface Messaging {
send(scope: string, data: Json, options?: { id?: string }): Promise<void>;
watch(scope: string, listener: (message: DeliveredMessage) => void, options?: WatchOptions): Promise<() => void>;
}Media
通話・配信・受信は明示的に開始します。subscribe は受信MediaStreamを返します。切断で資源が終了した場合は onClose が通知され、再接続後の開始もアプリが行います。
TypeScript · シグネチャ
interface Media {
get(scope: string): Promise<Read<MediaSource[]>>;
watch(scope: string, listener: (value: Read<MediaSource[]>) => void, options?: WatchOptions): Promise<() => void>;
onClose(listener: (event: MediaClosed) => void): () => void;
call(value: { scope: string; muted: boolean } | null): Promise<void>;
publish(input: { scope: string; kind: 'voice' | 'screen'; stream: MediaStream }): Promise<MediaSource>;
unpublish(source: string): Promise<void>;
subscribe(scope: string, source: string): Promise<{
subscription: string;
source: MediaSource;
stream: MediaStream;
}>;
unsubscribe(subscription: string): Promise<void>;
}
type MediaClosed = { error: ErrorValue | null } & (
| { resource: 'call'; scope: string }
| { resource: 'source'; source: string }
| { resource: 'subscription'; subscription: string }
);