Skip to content

Commit

Permalink
feat: export sessionId from session event message body (#14)
Browse files Browse the repository at this point in the history
* feat: export sessionId from session event message body

* export eventTime & add sessionId from presence when reload sessions

* export eventTime as creationTime

* review feedback

* remove useless type

Co-authored-by: jackson lin <[email protected]>
  • Loading branch information
jarvislin94 and jackson lin authored Sep 28, 2020
1 parent c550cb4 commit 47914c7
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/Session.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ export interface SessionData {
extensionId: string;
accountId: string;
parties: Party[];
creationTime?: string;
sessionId: string;
creationTime: string;
voiceCallToken?: string;
sequence?: number;
}
Expand Down
6 changes: 5 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ export class RingCentralCallControl extends EventEmitter {
if (message.event.indexOf('/telephony/sessions') === -1) {
return;
}
const { eventTime, telephonySessionId, sessionId, ...newData } = message.body;
const { eventTime, telephonySessionId, ...newData } = message.body;
if (!telephonySessionId) {
return;
}
Expand All @@ -151,6 +151,8 @@ export class RingCentralCallControl extends EventEmitter {
if (disconnectedParties.length === newData.parties.length) {
return;
}
// use first event's eventTime as session creationTime
newData.creationTime = eventTime;
const newSession = new Session(newData, this._sdk, this._accountLevel);
newSession.on('status', () => {
this.onSessionStatusUpdated(newSession);
Expand Down Expand Up @@ -233,6 +235,8 @@ export class RingCentralCallControl extends EventEmitter {
data.extensionId = this.extensionId;
data.accountId = this.accountId;
data.parties = data.parties.map(p => formatParty(p));
// since call session status API not provide the `sessionId`, so pick from presence here.
data.sessionId = activeCall.sessionId;
const session = new Session(data, this._sdk, this._accountLevel);
this._sessionsMap.set(
activeCall.telephonySessionId,
Expand Down

0 comments on commit 47914c7

Please sign in to comment.