@koi-design/callkit 2.0.0-beta.2 → 2.0.0-beta.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -867,7 +867,7 @@ var Connect = class {
867
867
  /**
868
868
  * Whether registered
869
869
  */
870
- isRegistered = false;
870
+ isRegister = false;
871
871
  constructor(callKit) {
872
872
  this.callKit = callKit;
873
873
  const { reconnect = {} } = this.callKit.config.getConfig();
@@ -907,6 +907,7 @@ var Connect = class {
907
907
  });
908
908
  }
909
909
  }
910
+ this.callKit.config.reset();
910
911
  this.setConnectStatus(CallStatus.init);
911
912
  this.clearObserveOptionsHeartbeatInterval();
912
913
  }
@@ -949,11 +950,23 @@ var Connect = class {
949
950
  return this.connectStatus === CallStatus.ringing;
950
951
  }
951
952
  /**
952
- *
953
+ * isHolding
953
954
  */
954
955
  isHolding() {
955
956
  return this.connectStatus === CallStatus.holding;
956
957
  }
958
+ /**
959
+ * isRegistered
960
+ */
961
+ isRegistered() {
962
+ return this.isRegister;
963
+ }
964
+ /**
965
+ * isMute
966
+ */
967
+ isMuted() {
968
+ return this.isMute;
969
+ }
957
970
  /**
958
971
  * Call ended, call not started
959
972
  * @returns
@@ -982,7 +995,7 @@ var Connect = class {
982
995
  }
983
996
  async register() {
984
997
  if (this.connectStatus !== CallStatus.init) {
985
- if (this.isRegistered) {
998
+ if (this.isRegistered()) {
986
999
  this.callKit.logger.warn("connectStatus is registered", {
987
1000
  caller: "Connect.register",
988
1001
  content: {
@@ -1118,14 +1131,14 @@ var Connect = class {
1118
1131
  type: "SIP",
1119
1132
  content: {
1120
1133
  registererState: state,
1121
- isRegistered: this.isRegistered
1134
+ isRegistered: this.isRegistered()
1122
1135
  }
1123
1136
  });
1124
1137
  this.setRegister(false);
1125
1138
  this.setConnectStatus(CallStatus.init);
1126
1139
  this.callKit.trigger(KitEvent.SIP_REGISTERER_EVENT, {
1127
1140
  registererState: state,
1128
- isRegistered: this.isRegistered
1141
+ isRegistered: this.isRegistered()
1129
1142
  });
1130
1143
  break;
1131
1144
  case import_sip.RegistererState.Registered:
@@ -1134,13 +1147,13 @@ var Connect = class {
1134
1147
  type: "SIP",
1135
1148
  content: {
1136
1149
  registererState: state,
1137
- isRegistered: this.isRegistered
1150
+ isRegistered: this.isRegistered()
1138
1151
  }
1139
1152
  });
1140
1153
  this.setRegister(true);
1141
1154
  this.callKit.trigger(KitEvent.SIP_REGISTERER_EVENT, {
1142
1155
  registererState: state,
1143
- isRegistered: this.isRegistered
1156
+ isRegistered: this.isRegistered()
1144
1157
  });
1145
1158
  break;
1146
1159
  case import_sip.RegistererState.Terminated:
@@ -1149,13 +1162,13 @@ var Connect = class {
1149
1162
  type: "SIP",
1150
1163
  content: {
1151
1164
  registererState: state,
1152
- isRegistered: this.isRegistered
1165
+ isRegistered: this.isRegistered()
1153
1166
  }
1154
1167
  });
1155
1168
  this.setRegister(false);
1156
1169
  this.setConnectStatus(CallStatus.init);
1157
1170
  this.callKit.trigger(KitEvent.SIP_REGISTERER_EVENT, {
1158
- isRegistered: this.isRegistered,
1171
+ isRegistered: this.isRegistered(),
1159
1172
  registererState: state
1160
1173
  });
1161
1174
  break;
@@ -1164,14 +1177,14 @@ var Connect = class {
1164
1177
  caller: "Connect.register.registererStateChange",
1165
1178
  type: "SIP",
1166
1179
  content: {
1167
- isRegistered: this.isRegistered,
1180
+ isRegistered: this.isRegistered(),
1168
1181
  registererState: state
1169
1182
  }
1170
1183
  });
1171
1184
  this.setRegister(false);
1172
1185
  this.setConnectStatus(CallStatus.init);
1173
1186
  this.callKit.trigger(KitEvent.SIP_REGISTERER_EVENT, {
1174
- isRegistered: this.isRegistered,
1187
+ isRegistered: this.isRegistered(),
1175
1188
  registererState: state
1176
1189
  });
1177
1190
  break;
@@ -1186,7 +1199,7 @@ var Connect = class {
1186
1199
  caller: "Connect.register.onInvite",
1187
1200
  content: {
1188
1201
  invite,
1189
- isRegistered: this.isRegistered
1202
+ isRegistered: this.isRegistered()
1190
1203
  }
1191
1204
  });
1192
1205
  this.currentSession = invite;
@@ -1206,7 +1219,7 @@ var Connect = class {
1206
1219
  this.setConnectStatus(CallStatus.ringing);
1207
1220
  this.callKit.trigger(KitEvent.SIP_SESSION_EVENT, {
1208
1221
  sessionState: state,
1209
- isRegistered: this.isRegistered
1222
+ isRegistered: this.isRegistered()
1210
1223
  });
1211
1224
  break;
1212
1225
  case import_sip.SessionState.Established:
@@ -1220,14 +1233,14 @@ var Connect = class {
1220
1233
  this.callKit.connect.setConnectStatus(CallStatus.calling);
1221
1234
  this.callKit.trigger(KitEvent.SIP_SESSION_EVENT, {
1222
1235
  sessionState: state,
1223
- isRegistered: this.isRegistered
1236
+ isRegistered: this.isRegistered()
1224
1237
  });
1225
1238
  setupRemoteMedia(this.currentSession);
1226
1239
  break;
1227
1240
  case import_sip.SessionState.Terminating:
1228
1241
  this.callKit.trigger(KitEvent.SIP_SESSION_EVENT, {
1229
1242
  sessionState: state,
1230
- isRegistered: this.isRegistered
1243
+ isRegistered: this.isRegistered()
1231
1244
  });
1232
1245
  break;
1233
1246
  case import_sip.SessionState.Terminated:
@@ -1248,7 +1261,7 @@ var Connect = class {
1248
1261
  this.isUnprompted = false;
1249
1262
  this.callKit.trigger(KitEvent.SIP_SESSION_EVENT, {
1250
1263
  sessionState: state,
1251
- isRegistered: this.isRegistered
1264
+ isRegistered: this.isRegistered()
1252
1265
  });
1253
1266
  break;
1254
1267
  default:
@@ -1435,11 +1448,10 @@ var Connect = class {
1435
1448
  caller: "Connect.unregister",
1436
1449
  type: "SIP",
1437
1450
  content: {
1438
- isRegistered: this.isRegistered,
1439
- registerer: this.registerer
1451
+ isRegistered: this.isRegistered()
1440
1452
  }
1441
1453
  });
1442
- if (!this.isRegistered || !this.registerer) {
1454
+ if (!this.isRegistered() || !this.registerer) {
1443
1455
  this.callKit.logger.warn("No registerer to unregister.", {
1444
1456
  caller: "Connect.unregister",
1445
1457
  type: "SIP",
@@ -1469,7 +1481,7 @@ var Connect = class {
1469
1481
  }
1470
1482
  });
1471
1483
  this.isOutgoing = true;
1472
- if (!this.isRegistered) {
1484
+ if (!this.isRegistered()) {
1473
1485
  await this.register();
1474
1486
  }
1475
1487
  this.setConnectStatus(CallStatus.connecting);
@@ -1489,7 +1501,7 @@ var Connect = class {
1489
1501
  register
1490
1502
  }
1491
1503
  });
1492
- this.isRegistered = register;
1504
+ this.isRegister = register;
1493
1505
  this.callKit.trigger(KitEvent.KIT_REGISTER_CHANGE, register);
1494
1506
  }
1495
1507
  /**
@@ -2051,7 +2063,6 @@ var Socket = class {
2051
2063
  errCode: ErrorCode.SOCKET_CONNECT_ERROR
2052
2064
  }
2053
2065
  });
2054
- this.callKit.config.reset();
2055
2066
  this.callKit.reset();
2056
2067
  return;
2057
2068
  }
@@ -2158,7 +2169,7 @@ var Socket = class {
2158
2169
  * 重置 socket 连接和所有状态
2159
2170
  * @param isWaitConfirm Whether need to wait for close confirmation
2160
2171
  */
2161
- async reset(isWaitConfirm = true) {
2172
+ async reset() {
2162
2173
  if (this.pingTimer) {
2163
2174
  clearInterval(this.pingTimer);
2164
2175
  this.pingTimer = void 0;
@@ -2170,9 +2181,7 @@ var Socket = class {
2170
2181
  this.callKit.logger.info("Closing socket connection", {
2171
2182
  caller: "Socket.reset",
2172
2183
  type: "INCALL",
2173
- content: {
2174
- isWaitConfirm
2175
- }
2184
+ content: {}
2176
2185
  });
2177
2186
  this.ws.close();
2178
2187
  this.isConnected = false;
@@ -2344,8 +2353,8 @@ var CallKit = class {
2344
2353
  }
2345
2354
  }
2346
2355
  await this.hangup();
2347
- this.socket.reset(false);
2348
2356
  this.connect.reset();
2357
+ this.socket.reset();
2349
2358
  this.config.reset();
2350
2359
  this.trigger(KitEvent.KIT_LOGIN_CHANGE, false);
2351
2360
  }