Skip to content

feat(calling): CAI 7842 event listener setup#4876

Merged
Kesari3008 merged 6 commits intowebex:mobius-socketfrom
Kesari3008:CAI-7842-Event-Listener-Setup
Apr 20, 2026
Merged

feat(calling): CAI 7842 event listener setup#4876
Kesari3008 merged 6 commits intowebex:mobius-socketfrom
Kesari3008:CAI-7842-Event-Listener-Setup

Conversation

@Kesari3008
Copy link
Copy Markdown
Contributor

@Kesari3008 Kesari3008 commented Apr 19, 2026

COMPLETES #https://jira-eng-sjc12.cisco.com/jira/browse/CAI-7842

This pull request addresses

Event listener refactor for Mobius Socket

by making the following changes

Change Type

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update
  • Tooling change
  • Internal code refactor

The following scenarios were tested

< ENUMERATE TESTS PERFORMED, WHETHER MANUAL OR AUTOMATED >

The GAI Coding Policy And Copyright Annotation Best Practices

  • GAI was not used (or, no additional notation is required)
  • Code was generated entirely by GAI
  • GAI was used to create a draft that was subsequently customized or modified
  • Coder created a draft manually that was non-substantively modified by GAI (e.g., refactoring was performed by GAI on manually written code)
  • Tool used for AI assistance (GitHub Copilot / Other - specify)
    • Github Copilot
    • Other - Please Specify
  • This PR is related to
    • Feature
    • Defect fix
    • Tech Debt
    • Automation

I certified that

  • I have read and followed contributing guidelines
  • I discussed changes with code owners prior to submitting this pull request
  • I have not skipped any automated checks
  • All existing and new tests passed
  • I have updated the documentation accordingly

Make sure to have followed the contributing guidelines before submitting.

@Kesari3008 Kesari3008 requested a review from a team as a code owner April 19, 2026 22:10
@Kesari3008 Kesari3008 added validated If the pull request is validated for automation. mobius-wss labels Apr 19, 2026
@Kesari3008 Kesari3008 changed the base branch from next to mobius-socket April 19, 2026 22:10
@chatgpt-codex-connector
Copy link
Copy Markdown

💡 Codex Review

this.sdkConnector.registerMobiusSocketListener('async_event', this.handleMobiusAsyncEvent);

P1 Badge Subscribe to the emitted async event name

registerMobiusSocketListener() subscribes to async_event, but the Mobius socket emits typed payloads under event:<type> (for this stream, event:async_event). That mismatch prevents handleMobiusAsyncEvent from ever running, so call lifecycle events from the socket are silently dropped when WS mode is enabled.


// TODO: Handle registration down event
// const line = Object.values(this.lineDict)[0];
// line.registration.handleRegistrationDownEvent(event);
return;

P1 Badge Handle registration.down by triggering recovery

The registration.down branch currently exits with a TODO and no recovery action. When Mobius sends this event (e.g., device/session invalidated), the SDK does not reconnect or re-register, leaving the client in a stale disconnected state until external/manual recovery occurs.


return this.mobiusSocket.sendWssRequest({
type: socketType,
trackingId,

P1 Badge Normalize websocket replies to WebexRequestPayload shape

In WS mode, makeRequest() returns the raw sendWssRequest() envelope, but calling/registration code still consumes Webex HTTP semantics (response.body.*, e.g. call setup uses response.body.callId). Without adapting WS data into body, those paths will read undefined and break call/registration state handling.


// TODO (Remove this later): Hardcoding the wss urls for now with test server url
primaryWss.push('wss://mobius.aload-calling1.ciscospark.com/v1/calling/web');

P2 Badge Remove hardcoded aload WSS endpoint from discovery list

The discovery helper unconditionally appends a test WSS host (mobius.aload-calling1...) to primary targets. That can route production clients to a non-discovered environment (or waste/fail connection attempts) whenever this endpoint is tried, instead of strictly honoring discovery/configured service URLs.

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

@Kesari3008 Kesari3008 changed the title Cai 7842 event listener setup feat(calling): CAI 7842 event listener setup Apr 20, 2026
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: dc76b74e5e

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

file: CALLING_CLIENT_FILE,
method: METHODS.REGISTER_MOBIUS_SOCKET_LISTENER,
});
this.sdkConnector.registerMobiusSocketListener('async_event', this.handleMobiusAsyncEvent);
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Subscribe to the correct Mobius socket event key

registerMobiusSocketListener() subscribes to "async_event", but the Mobius socket emits typed messages as "event:${envelope.type}" (see packages/@webex/internal-plugin-mobius-socket/src/mobius-socket.js, _onmessage, lines 1009-1012). In socket-enabled deployments this listener never receives async envelopes, so handleMobiusAsyncEvent() is bypassed and call/registration routing from the Mobius stream does not occur.

Useful? React with 👍 / 👎.

Comment on lines +761 to +766
if (eventType === MobiusEventType.REGISTRATION_DOWN) {
// TODO: Handle registration down event
// const line = Object.values(this.lineDict)[0];
// line.registration.handleRegistrationDownEvent(event);

return;
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Handle registration.down instead of dropping it

The new registration.down branch exits immediately with a TODO, so the client ignores backend notifications that a device registration became inactive. In that scenario no reconnect path is triggered from this event, which can leave the line unregistered and unable to place/receive calls until some unrelated recovery flow runs.

Useful? React with 👍 / 👎.

Comment on lines +78 to 100
/**
* @param event - TODO.
* @param cb - TODO.
*/
public registerMobiusSocketListener<T>(event: string, cb: (data?: T) => void): void {
if (!mobiusSocket) {
mobiusSocket = getMobiusSocketInstance(instance.getWebex());
}
mobiusSocket.on(event, (data: T) => {
cb(data);
});
}

/**
* @param event - TODO.
*/
public unregisterMobiusSocketListener(event: string): void {
if (!mobiusSocket) {
mobiusSocket = getMobiusSocketInstance(instance.getWebex());
}
mobiusSocket.off(event);
}
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

We don't have to make this listener available through sdkConnector. These can be utilized directly inside the CallingClient

SDKConnector we are using because we were consuming internal plugin services through it but for mobius socket we don't need this route

Comment on lines 130 to 138
private listenForWsEvents() {
this.sdkConnector.registerListener('event:mobius', async (event) => {
this.dequeueWsEvents(event);
});
log.info('Successfully registered listener for Mobius events', {
file: CALL_MANAGER_FILE,
method: METHODS.REGISTER_SESSIONS_LISTENER,
});
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

We have to put this method call also behind the feature flag

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This is taken care of

file: CALLING_CLIENT_FILE,
method: METHODS.REGISTER_MOBIUS_SOCKET_LISTENER,
});
this.sdkConnector.registerMobiusSocketListener('async_event', this.handleMobiusAsyncEvent);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
this.sdkConnector.registerMobiusSocketListener('async_event', this.handleMobiusAsyncEvent);
this.sdkConnector.registerMobiusSocketListener('event:async_event', this.handleMobiusAsyncEvent);

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

fixed

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 167cea1f6c

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment on lines +134 to +136
if (this.isMobiusSocketEnabled) {
this.sdkConnector.registerListener('event:mobius', async (event) => {
this.dequeueWsEvents(event);
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Keep Mercury call listener active when socket flag is off

listenForWsEvents() now registers event:mobius only when isMobiusSocketEnabled is true, but the default path (isWsFeatureEnabled(...) === false and no override) sets that flag to false. In that common configuration, CallManager never subscribes to event:mobius, and there is no alternate non-socket listener registration elsewhere, so inbound call setup/progress/disconnect events are never routed through dequeueWsEvents().

Useful? React with 👍 / 👎.

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 7a53d4ecf1

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment on lines +134 to +135
if (!this.isMobiusSocketEnabled) {
this.sdkConnector.registerListener('event:mobius', async (event) => {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Preserve Mercury fallback when Mobius socket is disconnected

listenForWsEvents() now skips event:mobius subscription whenever isMobiusSocketEnabled is true, but socket setup is explicitly non-fatal (connectToMobiusSocket() logs and continues when no WSS URI is available or all connects fail). In that scenario the client has neither a live Mobius-socket stream nor a Mercury fallback, so incoming call lifecycle events are never dequeued and call state stops updating. Please keep Mercury routing enabled until a socket connection is actually established (or re-enable it on socket failure).

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Contributor

@rarajes2 rarajes2 left a comment

Choose a reason for hiding this comment

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

Pending comments can be taken care in later PR, we can merge the PR if feature is working partially.

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: ebfc37af99

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment on lines 502 to 504
if (!callManager) {
callManager = new CallManager(webex, indicator);
callManager = new CallManager(webex, indicator, isMobiusSocketEnabled);
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Reinitialize CallManager when socket mode changes

getCallManager() now accepts isMobiusSocketEnabled, but it only applies that flag on first construction (if (!callManager) ...). Any later createClient() call with a different socket mode reuses the stale singleton, so listener wiring can be wrong for that client (e.g., first init without socket, later init with socket can process both Mercury and socket events; first init with socket, later init without socket can miss Mercury routing). This regression is introduced by the new constructor parameter being ignored after the first call.

Useful? React with 👍 / 👎.

@Kesari3008 Kesari3008 merged commit 3ac80ee into webex:mobius-socket Apr 20, 2026
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

mobius-wss validated If the pull request is validated for automation.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants