mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-04 02:14:01 +00:00
37 lines
1.2 KiB
JavaScript
37 lines
1.2 KiB
JavaScript
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),
|
|
getStartOptions: () => ({ pushToTalk: Boolean(controller.pushToTalkMode) }),
|
|
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();
|
|
},
|
|
};
|
|
}
|