@@ -80,7 +80,7 @@ export class CallEventHandler {
8080 continue ;
8181 }
8282 try {
83- this . handleCallEvent ( e ) ;
83+ await this . handleCallEvent ( e ) ;
8484 } catch ( e ) {
8585 logger . error ( "Caught exception handling call event" , e ) ;
8686 }
@@ -100,7 +100,7 @@ export class CallEventHandler {
100100
101101 if ( event . isBeingDecrypted ( ) || event . isDecryptionFailure ( ) ) {
102102 // add an event listener for once the event is decrypted.
103- event . once ( "Event.decrypted" , ( ) => {
103+ event . once ( "Event.decrypted" , async ( ) => {
104104 if ( ! this . eventIsACall ( event ) ) return ;
105105
106106 if ( this . callEventBuffer . includes ( event ) ) {
@@ -110,7 +110,7 @@ export class CallEventHandler {
110110 // This one wasn't buffered so just run the event handler for it
111111 // straight away
112112 try {
113- this . handleCallEvent ( event ) ;
113+ await this . handleCallEvent ( event ) ;
114114 } catch ( e ) {
115115 logger . error ( "Caught exception handling call event" , e ) ;
116116 }
@@ -128,7 +128,7 @@ export class CallEventHandler {
128128 return type . startsWith ( "m.call." ) || type . startsWith ( "org.matrix.call." ) ;
129129 }
130130
131- private handleCallEvent ( event : MatrixEvent ) {
131+ private async handleCallEvent ( event : MatrixEvent ) {
132132 const content = event . getContent ( ) ;
133133 const type = event . getType ( ) as EventType ;
134134 const weSentTheEvent = event . getSender ( ) === this . client . credentials . userId ;
@@ -169,7 +169,7 @@ export class CallEventHandler {
169169 }
170170
171171 call . callId = content . call_id ;
172- call . initWithInvite ( event ) ;
172+ await call . initWithInvite ( event ) ;
173173 this . calls . set ( call . callId , call ) ;
174174
175175 // if we stashed candidate events for that call ID, play them back now
@@ -201,9 +201,11 @@ export class CallEventHandler {
201201 // we've got an invite, pick the incoming call because we know
202202 // we haven't sent our invite yet otherwise, pick whichever
203203 // call has the lowest call ID (by string comparison)
204- if ( existingCall . state === CallState . WaitLocalMedia ||
205- existingCall . state === CallState . CreateOffer ||
206- existingCall . callId > call . callId ) {
204+ if (
205+ existingCall . state === CallState . WaitLocalMedia ||
206+ existingCall . state === CallState . CreateOffer ||
207+ existingCall . callId > call . callId
208+ ) {
207209 logger . log (
208210 "Glare detected: answering incoming call " + call . callId +
209211 " and canceling outgoing call " + existingCall . callId ,
0 commit comments