diff --git a/src/matrix/calls/CallHandler.ts b/src/matrix/calls/CallHandler.ts index 7cd60208..f60c1fe6 100644 --- a/src/matrix/calls/CallHandler.ts +++ b/src/matrix/calls/CallHandler.ts @@ -50,11 +50,13 @@ export class CallHandler { // map of userId to set of conf_id's they are in private memberToCallIds: Map> = new Map(); private groupCallOptions: GroupCallOptions; + private sessionId = makeId("s"); constructor(private readonly options: Options) { this.groupCallOptions = Object.assign({}, this.options, { emitUpdate: (groupCall, params) => this._calls.update(groupCall.id, params), createTimeout: this.options.clock.createTimeout, + sessionId: this.sessionId }); } diff --git a/src/matrix/calls/PeerCall.ts b/src/matrix/calls/PeerCall.ts index b85cee61..1b869f47 100644 --- a/src/matrix/calls/PeerCall.ts +++ b/src/matrix/calls/PeerCall.ts @@ -61,6 +61,7 @@ export class PeerCall implements IDisposable { private _state = CallState.Fledgling; private direction: CallDirection; private localMedia?: LocalMedia; + private seq: number = 0; // A queue for candidates waiting to go out. // We try to amalgamate candidates into a single candidate message where // possible @@ -258,6 +259,7 @@ export class PeerCall implements IDisposable { const content = { call_id: callId, version: 1, + seq: this.seq++, }; // TODO: Don't send UserHangup reason to older clients if (reason) { @@ -304,6 +306,7 @@ export class PeerCall implements IDisposable { offer, [SDPStreamMetadataKey]: this.localMedia!.getSDPMetadata(), version: 1, + seq: this.seq++, lifetime: CALL_TIMEOUT_MS }; if (this._state === CallState.CreateOffer) { @@ -578,6 +581,7 @@ export class PeerCall implements IDisposable { const answerContent: MCallAnswer = { call_id: this.callId, version: 1, + seq: this.seq++, answer: { sdp: localDescription.sdp, type: localDescription.type, @@ -648,6 +652,7 @@ export class PeerCall implements IDisposable { content: { call_id: this.callId, version: 1, + seq: this.seq++, candidates }, }, log); diff --git a/src/matrix/calls/callEventTypes.ts b/src/matrix/calls/callEventTypes.ts index a32a7739..9189911f 100644 --- a/src/matrix/calls/callEventTypes.ts +++ b/src/matrix/calls/callEventTypes.ts @@ -69,10 +69,15 @@ export interface CallReplacesTarget { export type MCallBase = { call_id: string; version: string | number; + seq: number; } export type MGroupCallBase = MCallBase & { conf_id: string; + device_id: string; + sender_session_id: string; + dest_session_id: string; + party_id: string; // Should not need this? } export type MCallAnswer = Base & { diff --git a/src/matrix/calls/group/Member.ts b/src/matrix/calls/group/Member.ts index fe2de0af..7404d647 100644 --- a/src/matrix/calls/group/Member.ts +++ b/src/matrix/calls/group/Member.ts @@ -33,6 +33,7 @@ export type Options = Omit, log: ILogItem) => Promise, emitUpdate: (participant: Member, params?: any) => void, @@ -41,6 +42,7 @@ export type Options = Omit