UNPKG

@telnyx/webrtc

Version:
118 lines (117 loc) 5.13 kB
import type { Logger } from 'loglevel'; import BaseMessage from './messages/BaseMessage'; import Connection from './services/Connection'; import type { PeerFailureEvidence, TriggerIceRestartResult } from './util/interfaces/SignalingHealth'; import { SwEvent } from './util/constants'; import type { ITelnyxErrorEvent } from './util/errors'; import { BroadcastParams, ILoginParams, IVertoOptions } from './util/interfaces'; import type { INotification } from '../../utils/interfaces'; import type { ITelnyxWarningEvent } from './util/constants/warnings'; export default abstract class BaseSession { options: IVertoOptions; uuid: string; sessionid: string; subscriptions: { [channel: string]: any; }; nodeid: string; master_nodeid: string; signature: string; relayProtocol: string; contexts: string[]; timeoutErrorCode: number; invalidMethodErrorCode: number; authenticationRequiredErrorCode: number; callReportId: string | null; callReportVoiceSdkId: string | null; dc: string | null; region: string | null; connection: Connection; protected _jwtAuth: boolean; protected _keepAliveTimeout: any; protected _reconnectTimeout: any; protected _autoReconnect: boolean; protected _idle: boolean; protected _reconnectAttempts: number; private _reconnectCountedGeneration; protected _intentionalClose: boolean; private _tokenExpiryTimeout; private static readonly TOKEN_EXPIRY_WARNING_SECONDS; private static readonly CALL_REPORT_UPLOAD_DRAIN_TIMEOUT_MS; private _pendingCallReportUploads; private _signalingHealthMonitor; private _executeQueue; private _pong; private registerAgent; constructor(options: IVertoOptions); get __logger(): Logger; get connected(): boolean; getIsRegistered(): Promise<boolean>; get reconnectDelay(): number; execute(msg: BaseMessage): Promise<any>; executeRaw(text: string): void; trackCallReportUpload(upload: Promise<void>): void; private _drainCallReportUploads; validateOptions(): boolean; broadcast(_params: BroadcastParams): void; disconnect(): Promise<void>; on(eventName: SwEvent.Error | 'telnyx.error', callback: (event: ITelnyxErrorEvent) => void): this; on(eventName: SwEvent.Warning | 'telnyx.warning', callback: (event: ITelnyxWarningEvent) => void): this; on(eventName: SwEvent.Notification | 'telnyx.notification', callback: (event: INotification) => void): this; on(eventName: string, callback: Function): this; off(eventName: SwEvent.Error | 'telnyx.error', callback?: (event: ITelnyxErrorEvent) => void): this; off(eventName: SwEvent.Warning | 'telnyx.warning', callback?: (event: ITelnyxWarningEvent) => void): this; off(eventName: SwEvent.Notification | 'telnyx.notification', callback?: (event: INotification) => void): this; off(eventName: string, callback?: Function): this; connect(): Promise<void>; resetReconnectAttempts(): void; protected _handleLoginError(error: any): void; clearReconnectToken(): void; private _checkTokenExpiry; private _emitTokenExpiryWarning; private _clearTokenExpiryTimeout; login({ creds, onSuccess, onError, }?: { creds?: ILoginParams; onSuccess?: () => void; onError?: (error: any) => void; }): Promise<void>; private _login; protected _onSocketOpen(): Promise<void>; private _flushIntermediateCallReports; private _getSocketCloseCodeName; private _getSocketCloseError; private _createSocketCloseFlushReason; onNetworkClose(event?: { code?: number; reason?: string; wasClean?: boolean; error?: unknown; socketGeneration?: number; }): void; protected _onSocketMessage(_response: any): void; protected _removeSubscription(protocol: string, channel?: string): void; protected _addSubscription(protocol: string, handler: Function, channel: string): void; _existsSubscription(protocol: string, channel?: string): boolean; private _attachListeners; private _detachListeners; private _emptyExecuteQueues; _closeConnection(): void; private _resetKeepAlive; _triggerKeepAliveTimeoutCheck(): void; setPingReceived(): void; private _onSocketActivity; hasActiveCall(): boolean; _terminateActiveCallsLocally(): void; startSignalingHealthMonitor(): void; stopSignalingHealthMonitor(): void; triggerIceRestart(callId: string): TriggerIceRestartResult; onSignalingRequestTimeout(requestId: string, timeoutMs: number, method?: string): void; reportPeerFailure(callId: string, evidence: PeerFailureEvidence): void; reportNoRtp(callId: string, direction: 'inbound' | 'outbound'): void; reportIceRestartFailed(callId: string): void; static on(eventName: string, callback: any): void; static off(eventName: string): void; static uuid(): string; clearConnection(): void; hasAutoReconnect(): boolean; }