Skip to content

Commit

Permalink
fix(calling): extend eventing class on ILine interface (webex#3286)
Browse files Browse the repository at this point in the history
Co-authored-by: Priya Kesari <[email protected]>
  • Loading branch information
Kesari3008 and Kesari3008 authored Jan 4, 2024
1 parent 5814e3b commit 75e8bbe
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 16 deletions.
8 changes: 4 additions & 4 deletions packages/calling/src/CallingClient/line/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
RegistrationStatus,
ServiceIndicator,
} from '../../common/types';
import {ILine, LINE_EVENTS, LineEventTypes} from './types';
import {ILine, LINE_EVENTS} from './types';
import {LINE_FILE, VALID_PHONE} from '../constants';
import log from '../../Logger';
import {IRegistration} from '../registration/types';
Expand All @@ -21,7 +21,7 @@ import {LineError} from '../../Errors/catalog/LineError';
import {LOGGER} from '../../Logger/types';
import {validateServiceData} from '../../common';
import SDKConnector from '../../SDKConnector';
import {LINE_EVENT_KEYS} from '../../Events/types';
import {LINE_EVENT_KEYS, LineEventTypes} from '../../Events/types';
import {ICall, ICallManager} from '../calling/types';
import {getCallManager} from '../calling/callManager';
import {ERROR_TYPE} from '../../Errors/types';
Expand Down Expand Up @@ -49,7 +49,7 @@ export default class Line extends Eventing<LineEventTypes> implements ILine {

public extension?: string;

public sipAddresses?: string[];
public sipAddresses: string[] = [];

public voicemail?: string;

Expand Down Expand Up @@ -161,7 +161,7 @@ export default class Line extends Eventing<LineEventTypes> implements ILine {
this.mobiusDeviceId = device?.deviceId;
this.mobiusUri = device?.uri;
this.lastSeen = device?.lastSeen;
this.sipAddresses = device?.addresses;
this.sipAddresses = device?.addresses ?? [];
this.keepaliveInterval = keepaliveInterval;
this.callKeepaliveInterval = callKeepaliveInterval;
this.rehomingIntervalMin = rehomingIntervalMin;
Expand Down
14 changes: 3 additions & 11 deletions packages/calling/src/CallingClient/line/types.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import {LineEventTypes} from '../../Events/types';
import {Eventing} from '../../Events/impl';
import {IRegistration} from '../registration/types';
import {LineError} from '../../Errors/catalog/LineError';
import {
Expand All @@ -22,7 +24,7 @@ export enum LINE_EVENTS {
/**
* Represents an interface for managing a telephony line.
*/
export interface ILine {
export interface ILine extends Eventing<LineEventTypes> {
/**
* The unique identifier of the user associated with the line.
*/
Expand Down Expand Up @@ -172,16 +174,6 @@ export interface ILine {
getCall(correlationId: CorrelationId): ICall;
}

export type LineEventTypes = {
[LINE_EVENTS.CONNECTING]: () => void;
[LINE_EVENTS.ERROR]: (error: LineError) => void;
[LINE_EVENTS.RECONNECTED]: () => void;
[LINE_EVENTS.RECONNECTING]: () => void;
[LINE_EVENTS.REGISTERED]: (lineInfo: ILine) => void;
[LINE_EVENTS.UNREGISTERED]: () => void;
[LINE_EVENTS.INCOMING_CALL]: (callObj: ICall) => void;
};

export type LineEmitterCallback = (
event: LINE_EVENTS,
deviceInfo?: IDeviceInfo,
Expand Down
14 changes: 13 additions & 1 deletion packages/calling/src/Events/types.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
/* eslint-disable @typescript-eslint/no-unused-vars */ // TODO: remove once we define the payloads
import {ILine} from '../api';
import {LINE_EVENTS} from '../CallingClient/line/types';
import type {ICall} from '../CallingClient/calling/types';
import {CallId, DisplayInformation} from '../common/types';
import {CallError, CallingClientError} from '../Errors';
import {CallError, CallingClientError, LineError} from '../Errors';

/** External Eventing Start */
export enum COMMON_EVENT_KEYS {
Expand Down Expand Up @@ -180,6 +182,16 @@ export type CallerIdDisplay = {
callerId: DisplayInformation;
};

export type LineEventTypes = {
[LINE_EVENTS.CONNECTING]: () => void;
[LINE_EVENTS.ERROR]: (error: LineError) => void;
[LINE_EVENTS.RECONNECTED]: () => void;
[LINE_EVENTS.RECONNECTING]: () => void;
[LINE_EVENTS.REGISTERED]: (lineInfo: ILine) => void;
[LINE_EVENTS.UNREGISTERED]: () => void;
[LINE_EVENTS.INCOMING_CALL]: (callObj: ICall) => void;
};

export type CallEventTypes = {
[CALL_EVENT_KEYS.ALERTING]: (callId: CallId) => void;
[CALL_EVENT_KEYS.CALL_ERROR]: (error: CallError) => void;
Expand Down
1 change: 1 addition & 0 deletions packages/calling/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,4 @@ export {
} from './common/types';
export {CallError, LineError} from './Errors';
export {ICall, TransferType} from './CallingClient/calling/types';
export {LOGGER} from './Logger/types';

0 comments on commit 75e8bbe

Please sign in to comment.