@tixae-labs/web-sdk
Version:
Javascript Web SDK for doing WebRTC AI Voice Calls with Convocore.
58 lines (57 loc) • 1.76 kB
TypeScript
import type { InitCallOptionsType, InitWebRtcCall } from "../../../../src/app/Types/firebase";
import { TypedWebCall } from "./voice-only-events";
export declare const AppIceServers: RTCIceServer[];
export type InitCallEvent = InitWebRtcCall;
export default class WebCall extends TypedWebCall {
private agentId;
private region;
private convoId;
private sessionId;
private options;
private mediaStream;
private remoteStream;
private audioElement;
private peerConnection;
private webSocket;
isMuted: boolean;
status: "idle" | "connecting" | "connected";
private audioContext;
private analyser;
private volumeAnimationFrame;
private baseUrl;
constructor(options?: InitCallOptionsType);
/**
* Initialize the API with the given agent ID.
* @param agentId - Your unique agent ID (or any string)
*/
init(input: Partial<InitWebRtcCall>): Promise<{
agentId: string | null;
region: string | null;
convoId: string | null;
sessionId: string | null;
options: InitCallOptionsType;
}>;
/**
* Start the WebRTC call flow:
* 1) Open a WebSocket to your signaling server
* 2) Create a RTCPeerConnection
* 3) Get local microphone and attach it
* 4) Handle remote track (attach to hidden <audio>)
* 5) Exchange offers/answers/candidates
* 6) Trigger events as needed
*/
startCall(): Promise<void>;
/**
* Toggle the local microphone tracks (mute/unmute).
*/
toggleMute(): void;
/**
* End the call:
* 1) Close peer connection
* 2) Close WS
* 3) Stop local tracks
* 4) Remove hidden <audio>
* 5) Cancel animation frames
*/
endCall(): void;
}