Standalone RTC channels
Tauri UI windows use the Web SDK's channel API directly, with no separate media SDK to add: HTTP requests that need the user's sign-in go through the engine, and the media connection (LiveKit) runs in the UI window. For channel rules, see the overview.
Join
import { createDRTauriClient } from '@deeprespond/im-tauri';
const im = createDRTauriClient({ appKey: 'org#app' });
// 等引擎就绪且用户登录完成;票据由业务服务端交付。
if (!im.channels.supported) throw new Error('当前窗口不支持频道媒体');
const channel = await im.channels.join('meeting-demo', { ticket: ticketFromBusinessServer });
await channel.setMicrophoneEnabled(true); // 用户操作触发,默认不采集。
const off = channel.on('track', ({ track, session_id, kind }) => {
// 按 Web 频道指南绑定本窗口的 audio/video 元素。
});
// 页面退出:
off();
await channel.leave();UI windows and the engine
- UI windows hold no IM access or refresh token; the engine adds the sign-in to HTTP requests. The window only uses a short-lived media token to connect to the channel.
- In the engine window
channels.supportedisfalse: it can't join channels or capture audio and video, but it can look up channel state. - Only the window that joined holds the channel handle; newly opened windows don't take over the media. Whether the same user occupies a channel across several windows is decided by the server.
channels.supportedonly checks that WebRTC and the media service are available. The WebView, device permissions and media network must also actually work. Don't assume channels work on a system just because one-to-one calls do.
Closing and recovery
When a window is destroyed, the page fires pagehide or freeze, or the engine goes to restarting or failed, the SDK stops the media and tries to leave the channel. Minimizing a window doesn't fire pagehide, so it doesn't leave the channel. Channel timers are precise, and state is refreshed when the system wakes from sleep.
When you destroy the client yourself, the SDK tries to leave the channel before closing its link to the engine, waiting up to 5 seconds; this is separate from the cleanup time when the app exits. If the engine is unavailable, or the process crashes or is force-killed, the leave request may not go out, and the server cleans up through timeouts and media cleanup.
Looking up channels and resume work as in the Web SDK: you can only resume a session that is still valid for the signed-in user, and nothing is captured after resuming by default. Still call leave() yourself when the page's route unmounts.
Permissions and release status
For the macOS microphone and camera usage descriptions and entitlements, the content security policy and media service addresses, see Quickstart. Device and WebView support on Windows, macOS and Linux each need testing; supported being true doesn't guarantee the devices work.
Channels in Tauri have so far only been through type checks and simulated window-lifecycle tests. They haven't been verified on real WebViews on each system, and haven't shipped in a release yet. Test on your target systems before going live.
