mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-05 10:53:59 +00:00
refactor: separate voice sessions from protocol adapters
This commit is contained in:
1 parent
584c9608d5
commit
4507f3a1d0
13 files changed
+735
-62
No files matched your search
@@ -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();
|
||||
},
|
||||
};
|
||||
}
|
||||
Reference in new issue
Block a user