Skip to content

Commit

Permalink
Merge branch 'SPARK-562169-Task-API-Implementation' of https://github…
Browse files Browse the repository at this point in the history
….com/Kesari3008/webex-js-sdk into dev/adhmenon-SPARK-562170
  • Loading branch information
adhmenon committed Dec 6, 2024
2 parents 2f154e3 + 93dc3d0 commit 1f2cee9
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 17 deletions.
16 changes: 8 additions & 8 deletions packages/@webex/plugin-cc/src/services/WebCallingService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,25 +82,25 @@ export default class WebCallingService extends EventEmitter {
public answerCall(localAudioStream: LocalMicrophoneStream, taskId: string) {
if (this.call) {
try {
this.webex.logger.info(`[WebRtc]: Call answered: ${taskId}`);
this.webex.logger.info(`Call answered: ${taskId}`);
this.call.answer(localAudioStream);
this.registerCallListeners();
} catch (error) {
this.webex.logger.error(`[WebRtc]: Failed to answer call for ${taskId}. Error: ${error}`);
this.webex.logger.error(`Failed to answer call for ${taskId}. Error: ${error}`);
// Optionally, throw the error to allow the invoker to handle it
throw error;
}
} else {
this.webex.logger.log(`[WebRtc]: Cannot answer a non WebRtc Call: ${taskId}`);
this.webex.logger.log(`Cannot answer a non WebRtc Call: ${taskId}`);
}
}

public muteCall(localAudioStream: LocalMicrophoneStream) {
if (this.call) {
this.webex.logger.info('[WebRtc]: Call mute|unmute requesting!');
this.webex.logger.info('Call mute|unmute requesting!');
this.call.mute(localAudioStream);
} else {
this.webex.logger.log(`[WebRtc]: Cannot mute a non WebRtc Call`);
this.webex.logger.log(`Cannot mute a non WebRtc Call`);
}
}

Expand All @@ -115,16 +115,16 @@ export default class WebCallingService extends EventEmitter {
public declineCall(taskId: string) {
if (this.call) {
try {
this.webex.logger.info(`[WebRtc]: Call end requested: ${taskId}`);
this.webex.logger.info(`Call end requested: ${taskId}`);
this.call.end();
this.unregisterCallListeners();
} catch (error) {
this.webex.logger.error(`[WebRtc]: Failed to end call: ${taskId}. Error: ${error}`);
this.webex.logger.error(`Failed to end call: ${taskId}. Error: ${error}`);
// Optionally, throw the error to allow the invoker to handle it
throw error;
}
} else {
this.webex.logger.log(`[WebRtc]: Cannot end a non WebRtc Call: ${taskId}`);
this.webex.logger.log(`Cannot end a non WebRtc Call: ${taskId}`);
}
}
}
2 changes: 1 addition & 1 deletion packages/@webex/plugin-cc/src/services/task/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export const TASK_EVENTS = {

export type TASK_EVENTS = Enum<typeof TASK_EVENTS>;

type Interaction = {
export type Interaction = {
isFcManaged: boolean;
isTerminated: boolean;
mediaType: MEDIA_CHANNEL;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ describe('WebCallingService', () => {
it('should answer the call and log info when call exists', () => {
webRTCCalling.answerCall(localAudioStream, 'task-id');

expect(webex.logger.info).toHaveBeenCalledWith('[WebRtc]: Call answered: task-id');
expect(webex.logger.info).toHaveBeenCalledWith('Call answered: task-id');
expect(mockCall.answer).toHaveBeenCalledWith(localAudioStream);
});

Expand All @@ -186,14 +186,14 @@ describe('WebCallingService', () => {
mockCall.answer.mockImplementation(() => { throw error; });

expect(() => webRTCCalling.answerCall(localAudioStream, 'task-id')).toThrow(error);
expect(webex.logger.error).toHaveBeenCalledWith(`[WebRtc]: Failed to answer call for task-id. Error: ${error}`);
expect(webex.logger.error).toHaveBeenCalledWith(`Failed to answer call for task-id. Error: ${error}`);
});

it('should log when there is no call to answer', () => {
webRTCCalling.call = null;
webRTCCalling.answerCall(localAudioStream, 'task-id');

expect(webex.logger.log).toHaveBeenCalledWith('[WebRtc]: Cannot answer a non WebRtc Call: task-id');
expect(webex.logger.log).toHaveBeenCalledWith('Cannot answer a non WebRtc Call: task-id');
});
});

Expand All @@ -209,23 +209,23 @@ describe('WebCallingService', () => {
it('should mute the call and log info when call exists', () => {
webRTCCalling.muteCall(localAudioStream);

expect(webex.logger.info).toHaveBeenCalledWith('[WebRtc]: Call mute|unmute requesting!');
expect(webex.logger.info).toHaveBeenCalledWith('Call mute|unmute requesting!');
expect(mockCall.mute).toHaveBeenCalledWith(localAudioStream);
});

it('should log when there is no call to mute', () => {
webRTCCalling.call = null;
webRTCCalling.muteCall(localAudioStream);

expect(webex.logger.log).toHaveBeenCalledWith('[WebRtc]: Cannot mute a non WebRtc Call');
expect(webex.logger.log).toHaveBeenCalledWith('Cannot mute a non WebRtc Call');
});
});

describe('declineCall', () => {
it('should end the call and log info when call exists', () => {
webRTCCalling.declineCall('task-id');

expect(webex.logger.info).toHaveBeenCalledWith('[WebRtc]: Call end requested: task-id');
expect(webex.logger.info).toHaveBeenCalledWith('Call end requested: task-id');
expect(mockCall.end).toHaveBeenCalled();
});

Expand All @@ -234,14 +234,14 @@ describe('WebCallingService', () => {
mockCall.end.mockImplementation(() => { throw error; });

expect(() => webRTCCalling.declineCall('task-id')).toThrow(error);
expect(webex.logger.error).toHaveBeenCalledWith(`[WebRtc]: Failed to end call: task-id. Error: ${error}`);
expect(webex.logger.error).toHaveBeenCalledWith(`Failed to end call: task-id. Error: ${error}`);
});

it('should log when there is no call to end', () => {
webRTCCalling.call = null;
webRTCCalling.declineCall('task-id');

expect(webex.logger.log).toHaveBeenCalledWith('[WebRtc]: Cannot end a non WebRtc Call: task-id');
expect(webex.logger.log).toHaveBeenCalledWith('Cannot end a non WebRtc Call: task-id');
});
});
});

0 comments on commit 1f2cee9

Please sign in to comment.