@volley/recognition-client-sdk
Version:
Recognition Service TypeScript/Node.js Client SDK
45 lines • 1.57 kB
TypeScript
/**
* Message Handler for Recognition Client
* Routes incoming WebSocket messages to appropriate callbacks
*/
import { type TranscriptionResultV1, type FunctionCallResultV1, type MetadataResultV1, type ErrorResultV1, type ClientControlMessageV1 } from '@recog/shared-types';
export interface MessageHandlerCallbacks {
onTranscript: (result: TranscriptionResultV1) => void;
onFunctionCall: (result: FunctionCallResultV1) => void;
onMetadata: (metadata: MetadataResultV1) => void;
onError: (error: ErrorResultV1) => void;
onControlMessage: (msg: ClientControlMessageV1) => void;
logger?: (level: 'debug' | 'info' | 'warn' | 'error', message: string, data?: any) => void;
}
export declare class MessageHandler {
private firstTranscriptTime;
private sessionStartTime;
private callbacks;
constructor(callbacks: MessageHandlerCallbacks);
/**
* Set session start time for performance tracking
*/
setSessionStartTime(time: number): void;
/**
* Handle incoming WebSocket message
*/
handleMessage(msg: {
v: number;
type: string;
data: any;
}): void;
/**
* Handle transcript message and track performance metrics
* @param result - The transcription result from the server
*/
private handleTranscription;
/**
* Get performance metrics
*/
getMetrics(): {
sessionStartTime: number | null;
firstTranscriptTime: number | null;
timeToFirstTranscript: number | null;
};
}
//# sourceMappingURL=message-handler.d.ts.map