-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathSyncCall.js
More file actions
58 lines (47 loc) · 1.58 KB
/
SyncCall.js
File metadata and controls
58 lines (47 loc) · 1.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
/*
Ý tưởng:
Trên iOS 13, phần nhận cuộc gọi onIncomingCall event từ Stringee SDK và phần nhận push từ apple sẽ là bất đồng bộ.
Để apply theo rule mới của apple, sử dụng class này để map giữa push và call
Một thời điểm sẽ chỉ có 1 cuộc gọi được xử lý, các cuộc khác đến khi đang có cuộc gọi thì sẽ reject
**/
class SyncCall {
// Thong tin cuoc goi
serial;
callId;
callkitId;
callCode;
isVideoCall;
rejected; // nguoi dung da click reject cuoc goi
answered; // nguoi dung da click answer cuoc goi
endedCallkit; // da end Callkit Call cho cuoc goi nay
endedStringeeCall; // da end Stringee Call cho cuoc goi nay
receivedStringeeCall;
constructor() {
this.serial = 1;
this.callId = '';
this.callkitId = '';
this.callCode = 0;
this.rejected = false;
this.answered = false;
this.endedCallkit = false;
this.endedStringeeCall = false;
this.receivedStringeeCall = false;
}
// Da show callkit cho cuoc goi nay chua
showedCallkit() {
return this.callkitId != '';
}
// Cuoc goi CallkitCall dang duoc show voi uuid nay hay khong
showedFor(uuid) {
return this.callkitId == uuid;
}
// Check xem cuoc goi voi cac thong tin nay co phai chinh la minh khong
isThisCall(callId, serial) {
return this.callId == callId && this.serial == serial;
}
// Cuoc goi da duoc end ca callkit va stringecall => co the giai phong instance
isEnded() {
return this.endedCallkit && this.endedStringeeCall;
}
}
export default SyncCall;