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

[STREAM-262] GenesysCloudMediaSession does not transition to ended when a call ends #274

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Changed
* [STREAM-162](https://inindca.atlassian.net/browse/STREAM-162) - Streaming-client should trigger re-auth for some SASL errors (and 401s) - this will be indicated by a StreamingClientError of type `.invalid-token`.

### Fixed
* [STREAM-262](https://inindca.atlassian.net/browse/STREAM-262) - Set the state of a GenesysCloudMediaSession to `ended` when a `terminate` is received (or we determine a hard closure of the PeerConnection is needed)

# [v17.2.7](https://github.com/purecloudlabs/genesys-cloud-streaming-client/compare/v17.2.6..v17.2.7)
### Fixed
* [STREAM-218](https://inindca.atlassian.net/browse/STREAM-218) - update the conversationId on sessions with reinvites
Expand Down
4 changes: 2 additions & 2 deletions src/types/genesys-cloud-media-session.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,6 @@ export class GenesysCloudMediaSession {
// if we have a state mismatch
if (this.state !== 'ended' && ['failed', 'closed'].includes(this.peerConnection.connectionState)) {
this.log('warn', 'state mismatch between session.state and peerConnection.connectionState, manually terminating the session', { sessionId: this.id, conversationId: this.conversationId, sessionType: this.sessionType });
this.state = 'ended';
this.onSessionTerminate();
}
}
Expand Down Expand Up @@ -224,7 +223,6 @@ export class GenesysCloudMediaSession {
this.interruptionStart = undefined;
} else if (connectionState === 'failed') {
this.log('info', 'Connection was interrupted and failed to recover, cleaning up', { sessionId, conversationId, sessionType });
this.state = 'ended';
this.onSessionTerminate();
}
}
Expand Down Expand Up @@ -305,6 +303,8 @@ export class GenesysCloudMediaSession {
}

onSessionTerminate (reason?: JingleReasonCondition) {
this.state = 'ended';

if (this.peerConnection) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Not directly related to this ticket, but from the interface (and a bit of code spelunking), it looks like we should always have a peerConnection. Is there a situation I overlooked where we might not have one?

this.peerConnection.close();
}
Expand Down
13 changes: 13 additions & 0 deletions test/unit/genesys-cloud-media-session.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -458,6 +458,13 @@ describe('unmute()', () => {
});

describe('onSessionTerminate()', () => {
it('should set the state to `ended`', () => {
const session = new GenesysCloudMediaSession(mockWebrtcExtension, config);

session.onSessionTerminate();
expect(session.state).toEqual('ended');
});

it('should emit a terminated event with default condition', () => {
const session = new GenesysCloudMediaSession(mockWebrtcExtension, config);

Expand Down Expand Up @@ -603,6 +610,12 @@ describe('end()', () => {
session = new GenesysCloudMediaSession(mockWebrtcExtension, config);
});

it('should set state to `ended`', () => {
session.end();

expect(session.state).toEqual('ended');
});

it('should not send message if silent', () => {
const spy = session['sendGenesysWebrtc'] = jest.fn();

Expand Down