workano-js-sdk
Version:
Workano Communications SDK - A modern JavaScript SDK for WebRTC and VoIP integration.
183 lines • 11.4 kB
TypeScript
import type { Message } from 'sip.js/lib/api/message';
import { OutgoingInviteRequest } from 'sip.js/lib/core';
import { Inviter } from 'sip.js/lib/api';
import CallSession from '../CallSession';
import type { Phone, AvailablePhoneOptions } from './Phone';
import WebRTCClient from '../../web-rtc-client';
import Emitter from '../../utils/Emitter';
import { WazoSession } from '../types';
export declare const ON_USER_AGENT = "onUserAgent";
export declare const ON_REGISTERED = "onRegistered";
export declare const ON_UNREGISTERED = "onUnRegistered";
export declare const ON_PROGRESS = "onProgress";
export declare const ON_CALL_ACCEPTED = "onCallAccepted";
export declare const ON_CALL_ANSWERED = "onCallAnswered";
export declare const ON_CALL_INCOMING = "onCallIncoming";
export declare const ON_CALL_OUTGOING = "onCallOutgoing";
export declare const ON_CALL_MUTED = "onCallMuted";
export declare const ON_CALL_UNMUTED = "onCallUnmuted";
export declare const ON_CALL_RESUMED = "onCallResumed";
export declare const ON_CALL_HELD = "onCallHeld";
export declare const ON_CALL_UNHELD = "onCallUnHeld";
export declare const ON_CAMERA_DISABLED = "onCameraDisabled";
export declare const ON_CAMERA_RESUMED = "onCameraResumed";
export declare const ON_CALL_CANCELED = "onCallCanceled";
export declare const ON_CALL_FAILED = "onCallFailed";
export declare const ON_CALL_REJECTED = "onCallRejected";
export declare const ON_CALL_ENDED = "onCallEnded";
export declare const ON_CALL_ENDING = "onCallEnding";
export declare const ON_MESSAGE = "onMessage";
export declare const ON_REINVITE = "reinvite";
export declare const ON_TRACK = "onTrack";
export declare const ON_AUDIO_STREAM = "onAudioStream";
export declare const ON_VIDEO_STREAM = "onVideoStream";
export declare const ON_REMOVE_STREAM = "onRemoveStream";
export declare const ON_SHARE_SCREEN_STARTED = "onScreenShareStarted";
export declare const ON_SHARE_SCREEN_ENDING = "onScreenShareEnding";
export declare const ON_SHARE_SCREEN_ENDED = "onScreenShareEnded";
export declare const ON_TERMINATE_SOUND = "terminateSound";
export declare const ON_PLAY_RING_SOUND = "playRingingSound";
export declare const ON_PLAY_INBOUND_CALL_SIGNAL_SOUND = "playInboundCallSignalSound";
export declare const ON_PLAY_HANGUP_SOUND = "playHangupSound";
export declare const ON_PLAY_PROGRESS_SOUND = "playProgressSound";
export declare const ON_VIDEO_INPUT_CHANGE = "videoInputChange";
export declare const ON_CALL_ERROR = "onCallError";
export declare const ON_MESSAGE_TRACK_UPDATED = "onTrackUpdated";
export declare const ON_NETWORK_STATS = "onNetworkStats";
export declare const ON_CHAT = "phone/ON_CHAT";
export declare const ON_SIGNAL = "phone/ON_SIGNAL";
export declare const ON_DISCONNECTED = "onDisconnected";
export declare const ON_EARLY_MEDIA = "onEarlyMedia";
export declare const MESSAGE_TYPE_CHAT = "message/TYPE_CHAT";
export declare const MESSAGE_TYPE_SIGNAL = "message/TYPE_SIGNAL";
export declare const events: string[];
export default class WebRTCPhone extends Emitter implements Phone {
client: WebRTCClient;
allowVideo: boolean;
callSessions: Record<string, CallSession>;
incomingSessions: string[];
currentSipSession?: WazoSession;
currentCallSession?: CallSession;
audioOutputDeviceId?: string;
audioRingDeviceId?: string;
audioOutputVolume: number;
audioRingVolume: number;
ringingEnabled: boolean;
acceptedSessions: Record<string, any>;
rejectedSessions: Record<string, any>;
ignoredSessions: Record<string, any>;
currentScreenShare: Record<string, any> | null;
lastScreenShare: Record<string, any> | null;
shouldSendReinvite: boolean;
constructor(client: WebRTCClient, audioOutputDeviceId: string | undefined, allowVideo?: boolean, audioRingDeviceId?: string);
register(): Promise<void>;
unregister(): Promise<void> | null;
stop(): void;
removeIncomingSessions(id: string): void;
isWebRTC(): boolean;
sendReinvite(callSession?: CallSession, constraints?: Record<string, any> | null | undefined, conference?: boolean, audioOnly?: boolean, iceRestart?: boolean): Promise<OutgoingInviteRequest | void>;
getUserAgent(): string;
startHeartbeat(): void;
stopHeartbeat(): void;
setOnHeartbeatTimeout(cb: (...args: Array<any>) => any): void;
setOnHeartbeatCallback(cb: (...args: Array<any>) => any): void;
reconnect(): void;
getOptions(): AvailablePhoneOptions;
onConnect(): Promise<void>;
onDisconnect(): Promise<void>;
_downgradeToAudio(callSession?: CallSession, withMessage?: boolean): boolean;
_upgradeToVideo(callSession: CallSession | undefined, constraints: Record<string, any>, isConference: boolean): Promise<boolean>;
_sendReinviteMessage(callSession: CallSession | undefined, isUpgrade: boolean): void;
_bindEvents(sipSession: WazoSession): void;
startScreenSharing(constraints: Record<string, any>, callSession?: CallSession): Promise<MediaStream>;
stopScreenSharing(restoreLocalStream?: boolean, callSession?: CallSession): Promise<OutgoingInviteRequest | void | null>;
_onScreenSharing(screenStream: MediaStream, sipSession: WazoSession, callSession: CallSession | null | undefined, hadVideo: boolean, desktop?: boolean | null | undefined): void;
_onCallAccepted(sipSession: WazoSession, cameraEnabled: boolean): CallSession;
changeAudioDevice(id: string): Promise<void>;
createAudioElementFor(sessionId: string): Promise<HTMLAudioElement>;
changeRingDevice(id: string): void;
changeAudioVolume(volume: number): void;
changeRingVolume(volume: number): void;
changeAudioInputDevice(id: string, force?: boolean): Promise<MediaStream | null>;
changeVideoInputDevice(id: string): Promise<void | MediaStream | null | undefined>;
changeSessionVideoInputDevice(id: string | null | undefined): Promise<void | MediaStream> | undefined;
_onCallTerminated(sipSession: WazoSession): boolean;
setActiveSipSession(callSession: CallSession): void;
hasAnActiveCall(): boolean;
hasActiveRemoteVideoStream(): boolean;
callCount(): number;
isCurrentCallSipSession(callSession: CallSession): boolean;
hasVideo(callSession: CallSession): boolean;
hasAVideoTrack(callSession: CallSession): boolean;
getLocalStreamForCall(callSession: CallSession): MediaStream | null | undefined;
getRemoteStreamForCall(callSession: CallSession): MediaStream | null | undefined;
getRemoteStreamsForCall(callSession: CallSession): MediaStream | null | undefined;
accept(callSession: CallSession, cameraEnabled?: boolean): Promise<string | null>;
isAccepted(callSession: CallSession): boolean;
reject(callSession: CallSession): Promise<void>;
ignore(callSession: CallSession): Promise<void>;
atxfer(callSession: CallSession): Record<string, any> | null | undefined;
hold(callSession: CallSession, withEvent?: boolean): Promise<OutgoingInviteRequest | void> | null | undefined;
unhold(callSession: CallSession, withEvent?: boolean): Promise<MediaStream | void | null>;
resume(callSession?: CallSession, withEvent?: boolean): Promise<MediaStream | void | null>;
holdSipSession(sipSession: WazoSession, callSession?: CallSession, withEvent?: boolean): Promise<OutgoingInviteRequest | void>;
unholdSipSession(sipSession: WazoSession, callSession: CallSession | null | undefined, withEvent?: boolean): Promise<MediaStream | void | null>;
mute(callSession?: CallSession, withEvent?: boolean): void;
unmute(callSession?: CallSession, withEvent?: boolean): void;
isAudioMuted(callSession: CallSession): boolean;
turnCameraOn(callSession?: CallSession): void;
turnCameraOff(callSession?: CallSession): void;
sendKey(callSession: CallSession | undefined, tone: string): void;
makeCall(number: string, line: any, cameraEnabled?: boolean, audioOnly?: boolean, conference?: boolean, options?: {}): Promise<CallSession | null | undefined>;
transfer(callSession: CallSession, target: string): void;
indirectTransfer(source: CallSession, destination: CallSession): Promise<boolean>;
initiateCTIIndirectTransfer(): Promise<null>;
cancelCTIIndirectTransfer(): void;
confirmCTIIndirectTransfer(): void;
hangup(callSession?: CallSession): Promise<boolean>;
getStats(callSession?: CallSession): Promise<RTCStatsReport | null | undefined>;
startNetworkMonitoring(callSession?: CallSession, interval?: number): void | null;
stopNetworkMonitoring(callSession?: CallSession): void | null;
forceCancel(sipSession: Inviter): void;
endCurrentCall(callSession: CallSession): void;
onConnectionMade(): void;
isConference(callSession: CallSession | null | undefined): boolean;
close(force?: boolean): Promise<void>;
isRegistered(): boolean;
enableRinging(): Promise<void> | void;
disableRinging(): Promise<void> | void;
getCurrentCallSession(): CallSession | null | undefined;
hasIncomingCallSession(): boolean;
getIncomingCallSession(): CallSession | null | undefined;
sendMessage(sipSession: (WazoSession | null) | undefined, body: string, contentType?: string): void;
getLocalStream(callSession: CallSession): MediaStream | null | undefined;
getLocalVideoStream(callSession: CallSession): MediaStream | null | undefined;
getLocalMediaStream(callSession: CallSession): MediaStream | null | undefined;
hasLocalVideo(callSession: CallSession): boolean;
hasALocalVideoTrack(callSession: CallSession): boolean;
getRemoteStream(callSession: CallSession): MediaStream | null | undefined;
getRemoteVideoStream(callSession: CallSession): MediaStream | null | undefined;
getRemoteVideoStreamFromPc(callSession: CallSession): MediaStream | null | undefined;
hasRemoteVideo(callSession: CallSession): boolean;
setMediaConstraints(media: MediaStreamConstraints): void;
isVideoRemotelyHeld(callSession: CallSession): boolean;
bindClientEvents(): void;
findSipSession(callSession?: CallSession): WazoSession | null | undefined;
getCallSession(sipSessionId: string): CallSession | null | undefined;
getSipSessionId(sipSession: WazoSession | null | undefined): string;
getSipSessionIdFromCallSession(callSession: CallSession): string | null;
_updateCallSession(callSession: CallSession): void;
_onMessage(message: Message & {
method?: string;
body?: string;
}): void;
_createIncomingCallSession(sipSession: WazoSession, cameraEnabled: boolean, fromSession?: CallSession | null | undefined, autoAnswer?: boolean): CallSession;
_createOutgoingCallSession(sipSession: WazoSession, cameraEnabled: boolean, fromSession?: CallSession): CallSession;
_createAcceptedCallSession(sipSession: WazoSession, cameraEnabled?: boolean, fromSession?: CallSession): CallSession;
_createMutedCallSession(sipSession: WazoSession, fromSession?: CallSession): CallSession;
_createUnmutedCallSession(sipSession: WazoSession, fromSession?: CallSession): CallSession;
_createCameraResumedCallSession(sipSession: WazoSession, fromSession?: CallSession): CallSession;
_createCameraDisabledCallSession(sipSession: WazoSession, fromSession?: CallSession): CallSession;
_createCallSession(sipSession: WazoSession, fromSession?: CallSession | null | undefined, extra?: Record<string, any>): CallSession;
}
//# sourceMappingURL=WebRTCPhone.d.ts.map