refactor: separate voice sessions from protocol adapters

This commit is contained in:
Sameh Khamis committed 2026-09-14 20:27:12 -07:00
1 parent 584c9608d5
commit 4507f3a1d0
13 files changed
+735 -62

No files matched your search

+35
View File
@@ -0,0 +1,35 @@
import { GevRealtimeController } from './realtimeController.js';
/** Adapt the existing WebRTC implementation to the common voice session. */
export function createRealtimeSession({
emit,
runAction,
createController = (options) => new GevRealtimeController(options),
...options
}) {
const controller = createController({
...options,
actionExecutor: runAction,
onSessionEvent: emit,
});
return {
controller,
capabilities: { costControls: true, pushToTalk: true },
start: (settings) => controller.start(settings),
stop: (settings) => controller.stop(settings),
sendText: (text) => controller.sendTextCommand(text),
sendMapEvent: (event) => controller.notifyMapEvent(event),
ignoreButtonClick: () => Boolean(controller.spaceKeyHeld),
bindControls() {
if (controller.ui.tierButton) {
controller.tierHandler = () => controller.toggleVoiceTier();
controller.ui.tierButton.addEventListener(
'click',
controller.tierHandler,
);
}
controller.syncCostUi();
controller.bindPushToTalkShortcut();
},
};
}