Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(wxcc): agent-multi-login-changes #4068

Merged
merged 10 commits into from
Jan 22, 2025
9 changes: 7 additions & 2 deletions packages/@webex/plugin-cc/src/cc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {
BuddyAgents,
SubscribeRequest,
} from './types';
import {READY, CC_FILE, EMPTY_STRING, AGENT_STATE_CHANGE} from './constants';
import {READY, CC_FILE, EMPTY_STRING, AGENT_STATE_CHANGE, AGENT_MULTI_LOGIN} from './constants';
import {AGENT, WEB_RTC_PREFIX} from './services/constants';
import Services from './services';
import HttpRequest from './services/core/HttpRequest';
Expand Down Expand Up @@ -289,6 +289,11 @@ export default class ContactCenter extends WebexPlugin implements IContactCenter
// @ts-ignore
this.emit(AGENT_STATE_CHANGE, eventData.data);
}

if (eventData.type === CC_EVENTS.AGENT_MULTI_LOGIN) {
// @ts-ignore
this.emit(AGENT_MULTI_LOGIN, eventData.data);
}
};

/**
Expand All @@ -311,7 +316,7 @@ export default class ContactCenter extends WebexPlugin implements IContactCenter
}

/**
* Called when we reconnection has been completed
* Called when the reconnection has been completed
*/
private async handleConnectionLost(msg: ConnectionLostDetails): Promise<void> {
if (msg.isConnectionLost) {
Expand Down
2 changes: 1 addition & 1 deletion packages/@webex/plugin-cc/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import {LOGGER} from '@webex/calling';

export default {
cc: {
allowMultiLogin: true,
allowMultiLogin: false,
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have tried to set allowMultiLogin to false in webexConfig object inside CC Widgets but that we not working, So I think we need to set allowMultiLogin to false from SDK side

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should work. Approving the PR as still we can debug/test this with false also.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a TODO to fix this?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, why do we need this change?

Copy link
Author

@pagour98 pagour98 Jan 22, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mkesavan13 , We need this because to tell backend that there should not be multi-login by agent and if there is a multi-login then send AGENT_MULTI_LOGIN event to the client, so that the client know that there is a multi-login.

This will not impact any existing functionality.

allowAutomatedRelogin: true,
clientType: 'WebexCCSDK',
isKeepAliveEnabled: false,
Expand Down
1 change: 1 addition & 0 deletions packages/@webex/plugin-cc/src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@ export const WEB_SOCKET_MANAGER_FILE = 'WebSocketManager';
export const AQM_REQS_FILE = 'aqm-reqs';
export const TASK_MANAGER_FILE = 'TaskManager';
export const AGENT_STATE_CHANGE = 'agent:stateChange';
export const AGENT_MULTI_LOGIN = 'agent:multiLogin';
1 change: 1 addition & 0 deletions packages/@webex/plugin-cc/src/services/config/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export const CC_EVENTS = {
AGENT_STATION_LOGIN_SUCCESS: 'AgentStationLoginSuccess',
AGENT_STATION_LOGIN_FAILED: 'AgentStationLoginFailed',
AGENT_STATE_CHANGE: 'AgentStateChange',
AGENT_MULTI_LOGIN: 'AGENT_MULTI_LOGIN',
AGENT_STATE_CHANGE_SUCCESS: 'AgentStateChangeSuccess',
AGENT_STATE_CHANGE_FAILED: 'AgentStateChangeFailed',
AGENT_BUDDY_AGENTS: 'BuddyAgents',
Expand Down
24 changes: 19 additions & 5 deletions packages/@webex/plugin-cc/test/unit/spec/cc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import Services from '../../../src/services';
import config from '../../../src/config';
import {CC_EVENTS} from '../../../src/services/config/types';
import LoggerProxy from '../../../src/logger-proxy';
import {CC_FILE, AGENT_STATE_CHANGE} from '../../../src/constants';
import {CC_FILE, AGENT_STATE_CHANGE, AGENT_MULTI_LOGIN} from '../../../src/constants';

// Mock the Worker API
import '../../../__mocks__/workerMock';
Expand Down Expand Up @@ -246,7 +246,7 @@ describe('webex.cc', () => {
force: true,
isKeepAliveEnabled: false,
clientType: 'WebexCCSDK',
allowMultiLogin: true,
allowMultiLogin: false,
},
});
expect(configSpy).toHaveBeenCalled();
Expand Down Expand Up @@ -411,18 +411,31 @@ describe('webex.cc', () => {
expect(emitSpy).toHaveBeenCalledWith(TASK_EVENTS.TASK_INCOMING, mockTask);
// Verify message event listener
const messageCallback = mockWebSocketManager.on.mock.calls.find(call => call[0] === 'message')[1];
const eventData = {
const agentStateChangeEventData = {
type: CC_EVENTS.AGENT_STATE_CHANGE,
data: { some: 'data' },
};

const agentMultiLoginEventData = {
type: CC_EVENTS.AGENT_MULTI_LOGIN,
data: {some: 'data'},
}

// Simulate receiving a message event
messageCallback(JSON.stringify(eventData));
messageCallback(JSON.stringify(agentStateChangeEventData));

expect(ccEmitSpy).toHaveBeenCalledWith(
AGENT_STATE_CHANGE,
eventData.data
agentStateChangeEventData.data
);

// Simulate receiving a message event
messageCallback(JSON.stringify(agentMultiLoginEventData));

expect(ccEmitSpy).toHaveBeenCalledWith(
AGENT_MULTI_LOGIN,
agentMultiLoginEventData.data
)
});

it('should login successfully with other LoginOption', async () => {
Expand Down Expand Up @@ -871,4 +884,5 @@ describe('webex.cc', () => {
);
});
});

});
Loading