Skip to content

Commit

Permalink
fix(cc-sdk): fixed-relogin-issue (#4078)
Browse files Browse the repository at this point in the history
  • Loading branch information
adhmenon authored Feb 3, 2025
1 parent 4aa4970 commit 0c5a54e
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
5 changes: 5 additions & 0 deletions packages/@webex/plugin-cc/src/cc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,10 @@ export default class ContactCenter extends WebexPlugin implements IContactCenter
const reLoginResponse = await this.services.agent.reload();
const {auxCodeId, agentId, lastStateChangeReason, deviceType, dn} = reLoginResponse.data;

// To handle re-registration of event listeners on silent relogin
this.incomingTaskListener();
this.taskManager.registerIncomingCallEvent();

if (lastStateChangeReason === 'agent-wss-disconnect') {
LoggerProxy.info(
'event=requestAutoStateChange | Requesting state change to available on socket reconnect',
Expand Down Expand Up @@ -395,6 +399,7 @@ export default class ContactCenter extends WebexPlugin implements IContactCenter
});
throw new Error(`Unsupported device type: ${deviceType}`);
}
this.webCallingService.setLoginOption(deviceType);
this.agentConfig.deviceType = deviceType;
}
}
18 changes: 18 additions & 0 deletions packages/@webex/plugin-cc/test/unit/spec/cc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -772,6 +772,16 @@ describe('webex.cc', () => {
.mockResolvedValue({} as SetStateResponse);
jest.spyOn(webex.cc.services.agent, 'reload').mockResolvedValue(mockReLoginResponse);

const registerWebCallingLineSpy = jest.spyOn(
webex.cc.webCallingService,
'registerWebCallingLine'
);
const registerIncomingCallEventSpy = jest.spyOn(
webex.cc.taskManager,
'registerIncomingCallEvent'
);
const incomingTaskListenerSpy = jest.spyOn(webex.cc, 'incomingTaskListener');
const webSocketManagerOnSpy = jest.spyOn(webex.cc.services.webSocketManager, 'on');
await webex.cc['silentRelogin']();

expect(LoggerProxy.info).toHaveBeenCalledWith(
Expand All @@ -786,6 +796,10 @@ describe('webex.cc', () => {
});
expect(webex.cc.agentConfig.isAgentLoggedIn).toBe(true);
expect(webex.cc.agentConfig.deviceType).toBe(LoginOption.BROWSER);
expect(registerWebCallingLineSpy).toHaveBeenCalled();
expect(registerIncomingCallEventSpy).toHaveBeenCalled();
expect(incomingTaskListenerSpy).toHaveBeenCalled();
expect(webSocketManagerOnSpy).toHaveBeenCalledWith('message', expect.any(Function));
});

it('should handle AGENT_NOT_FOUND error silently', async () => {
Expand Down Expand Up @@ -831,6 +845,10 @@ describe('webex.cc', () => {
isAgentLoggedIn: false,
} as Profile;

const registerWebCallingLineSpy = jest.spyOn(
webex.cc.webCallingService,
'registerWebCallingLine'
);
jest.spyOn(webex.cc.services.agent, 'reload').mockResolvedValue(mockReLoginResponse);

await webex.cc['silentRelogin']();
Expand Down

0 comments on commit 0c5a54e

Please sign in to comment.