@stream-io/video-client 0.0.8 → 0.0.10
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/CHANGELOG.md +14 -0
- package/dist/index.browser.es.js +146 -116
- package/dist/index.browser.es.js.map +1 -1
- package/dist/index.cjs.js +146 -116
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.es.js +146 -116
- package/dist/index.es.js.map +1 -1
- package/dist/src/StreamVideoClient.d.ts +8 -8
- package/dist/src/coordinator/connection/client.d.ts +13 -9
- package/dist/src/coordinator/connection/insights.d.ts +2 -2
- package/dist/src/coordinator/connection/token_manager.d.ts +4 -4
- package/dist/src/coordinator/connection/types.d.ts +17 -12
- package/dist/src/rtc/publisher.d.ts +6 -0
- package/dist/src/store/stateStore.d.ts +6 -6
- package/package.json +1 -1
- package/src/Call.ts +9 -5
- package/src/StreamVideoClient.ts +47 -32
- package/src/coordinator/connection/client.ts +23 -15
- package/src/coordinator/connection/token_manager.ts +5 -5
- package/src/coordinator/connection/types.ts +16 -10
- package/src/events/__tests__/call.test.ts +6 -0
- package/src/rtc/publisher.ts +14 -0
- package/src/store/stateStore.ts +8 -6
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,20 @@
|
|
|
2
2
|
|
|
3
3
|
This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).
|
|
4
4
|
|
|
5
|
+
### [0.0.10](https://github.com/GetStream/stream-video-js/compare/client0.0.9...client0.0.10) (2023-06-12)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Features
|
|
9
|
+
|
|
10
|
+
* User connect and types ([#627](https://github.com/GetStream/stream-video-js/issues/627)) ([721ef61](https://github.com/GetStream/stream-video-js/commit/721ef611374540ef570a516009c78d58ce4f5360))
|
|
11
|
+
|
|
12
|
+
### [0.0.9](https://github.com/GetStream/stream-video-js/compare/client0.0.8...client0.0.9) (2023-06-12)
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
### Bug Fixes
|
|
16
|
+
|
|
17
|
+
* prevent misleading "stop publish" log messages upon call instantiation ([#629](https://github.com/GetStream/stream-video-js/issues/629)) ([af40939](https://github.com/GetStream/stream-video-js/commit/af4093966c408d37fbf59c4c8fafd22756aa8888))
|
|
18
|
+
|
|
5
19
|
### [0.0.8](https://github.com/GetStream/stream-video-js/compare/client0.0.7...client0.0.8) (2023-06-09)
|
|
6
20
|
|
|
7
21
|
|
package/dist/index.browser.es.js
CHANGED
|
@@ -5692,6 +5692,19 @@ class Publisher {
|
|
|
5692
5692
|
return this.notifyTrackMuteStateChanged(undefined, transceiver.sender.track, trackType, true);
|
|
5693
5693
|
}
|
|
5694
5694
|
});
|
|
5695
|
+
/**
|
|
5696
|
+
* Returns true if the given track type is currently being published to the SFU.
|
|
5697
|
+
*
|
|
5698
|
+
* @param trackType the track type to check.
|
|
5699
|
+
*/
|
|
5700
|
+
this.isPublishing = (trackType) => {
|
|
5701
|
+
const transceiverForTrackType = this.transceiverRegistry[trackType];
|
|
5702
|
+
if (transceiverForTrackType && transceiverForTrackType.sender) {
|
|
5703
|
+
const sender = transceiverForTrackType.sender;
|
|
5704
|
+
return !!sender.track && sender.track.readyState === 'live';
|
|
5705
|
+
}
|
|
5706
|
+
return false;
|
|
5707
|
+
};
|
|
5695
5708
|
this.notifyTrackMuteStateChanged = (mediaStream, track, trackType, isMuted) => __awaiter(this, void 0, void 0, function* () {
|
|
5696
5709
|
yield this.sfuClient.updateMuteState(trackType, isMuted);
|
|
5697
5710
|
const audioOrVideoOrScreenShareStream = trackTypeToParticipantStreamKey(trackType);
|
|
@@ -9291,20 +9304,22 @@ class Call {
|
|
|
9291
9304
|
createSubscription(this.state.ownCapabilities$, (ownCapabilities) => {
|
|
9292
9305
|
// update the permission context.
|
|
9293
9306
|
this.permissionsContext.setPermissions(ownCapabilities);
|
|
9307
|
+
if (!this.publisher)
|
|
9308
|
+
return;
|
|
9294
9309
|
// check if the user still has publishing permissions and stop publishing if not.
|
|
9295
9310
|
const permissionToTrackType = {
|
|
9296
9311
|
[OwnCapability.SEND_AUDIO]: TrackType.AUDIO,
|
|
9297
9312
|
[OwnCapability.SEND_VIDEO]: TrackType.VIDEO,
|
|
9298
9313
|
[OwnCapability.SCREENSHARE]: TrackType.SCREEN_SHARE,
|
|
9299
9314
|
};
|
|
9300
|
-
|
|
9315
|
+
for (const [permission, trackType] of Object.entries(permissionToTrackType)) {
|
|
9301
9316
|
const hasPermission = this.permissionsContext.hasPermission(permission);
|
|
9302
|
-
if (!hasPermission) {
|
|
9303
|
-
this.stopPublish(
|
|
9304
|
-
console.error('Error stopping publish',
|
|
9317
|
+
if (!hasPermission && this.publisher.isPublishing(trackType)) {
|
|
9318
|
+
this.stopPublish(trackType).catch((err) => {
|
|
9319
|
+
console.error('Error stopping publish', trackType, err);
|
|
9305
9320
|
});
|
|
9306
9321
|
}
|
|
9307
|
-
}
|
|
9322
|
+
}
|
|
9308
9323
|
}),
|
|
9309
9324
|
// handles the case when the user is blocked by the call owner.
|
|
9310
9325
|
createSubscription(this.state.metadata$, (metadata) => __awaiter(this, void 0, void 0, function* () {
|
|
@@ -10202,7 +10217,7 @@ class TokenManager {
|
|
|
10202
10217
|
return;
|
|
10203
10218
|
// Don't allow empty token for non-server side client.
|
|
10204
10219
|
if (!this.secret && !tokenOrProvider) {
|
|
10205
|
-
throw new Error('
|
|
10220
|
+
throw new Error('UserWithId token can not be empty');
|
|
10206
10221
|
}
|
|
10207
10222
|
if (tokenOrProvider &&
|
|
10208
10223
|
typeof tokenOrProvider !== 'string' &&
|
|
@@ -10515,7 +10530,7 @@ class StreamClient {
|
|
|
10515
10530
|
/**
|
|
10516
10531
|
* connectUser - Set the current user and open a WebSocket connection
|
|
10517
10532
|
*
|
|
10518
|
-
* @param
|
|
10533
|
+
* @param user Data about this user. IE {name: "john"}
|
|
10519
10534
|
* @param {TokenOrProvider} userTokenOrProvider Token or provider
|
|
10520
10535
|
*
|
|
10521
10536
|
* @return {ConnectAPIResponse} Returns a promise that resolves when the connection is setup
|
|
@@ -10592,7 +10607,7 @@ class StreamClient {
|
|
|
10592
10607
|
this.openConnection = () => __awaiter(this, void 0, void 0, function* () {
|
|
10593
10608
|
var _d, _e, _f;
|
|
10594
10609
|
if (!this.userID) {
|
|
10595
|
-
throw Error('
|
|
10610
|
+
throw Error('UserWithId is not set on client, use client.connectUser or client.connectAnonymousUser instead');
|
|
10596
10611
|
}
|
|
10597
10612
|
if (((_d = this.wsConnection) === null || _d === void 0 ? void 0 : _d.isConnecting) && this.wsPromise) {
|
|
10598
10613
|
this.logger('info', 'client:openConnection() - connection already in progress', {
|
|
@@ -10652,7 +10667,9 @@ class StreamClient {
|
|
|
10652
10667
|
});
|
|
10653
10668
|
this.doAxiosRequest = (type, url, data, options = {}) => __awaiter(this, void 0, void 0, function* () {
|
|
10654
10669
|
var _g;
|
|
10655
|
-
|
|
10670
|
+
if (!options.publicEndpoint || this.user) {
|
|
10671
|
+
yield this.tokenManager.tokenReady();
|
|
10672
|
+
}
|
|
10656
10673
|
const requestConfig = this._enrichAxiosOptions(options);
|
|
10657
10674
|
try {
|
|
10658
10675
|
let response;
|
|
@@ -11005,7 +11022,7 @@ class StreamClient {
|
|
|
11005
11022
|
}
|
|
11006
11023
|
getUserAgent() {
|
|
11007
11024
|
return (this.userAgent ||
|
|
11008
|
-
`stream-video-javascript-client-${this.node ? 'node' : 'browser'}-${"0.0.
|
|
11025
|
+
`stream-video-javascript-client-${this.node ? 'node' : 'browser'}-${"0.0.9"}`);
|
|
11009
11026
|
}
|
|
11010
11027
|
setUserAgent(userAgent) {
|
|
11011
11028
|
this.userAgent = userAgent;
|
|
@@ -11016,7 +11033,7 @@ class StreamClient {
|
|
|
11016
11033
|
config: {},
|
|
11017
11034
|
}) {
|
|
11018
11035
|
var _a;
|
|
11019
|
-
const token = this._getToken();
|
|
11036
|
+
const token = options.publicEndpoint && !this.user ? undefined : this._getToken();
|
|
11020
11037
|
const authorization = token ? { Authorization: token } : undefined;
|
|
11021
11038
|
let signal = null;
|
|
11022
11039
|
if (this.nextRequestAbortController !== null) {
|
|
@@ -11026,7 +11043,9 @@ class StreamClient {
|
|
|
11026
11043
|
if (!((_a = options.headers) === null || _a === void 0 ? void 0 : _a['x-client-request-id'])) {
|
|
11027
11044
|
options.headers = Object.assign(Object.assign({}, options.headers), { 'x-client-request-id': randomId() });
|
|
11028
11045
|
}
|
|
11029
|
-
return Object.assign(Object.assign(Object.assign({ params: Object.assign({ user_id: this.userID, connection_id: this._getConnectionID(), api_key: this.key }, options.params), headers: Object.assign(Object.assign(Object.assign({}, authorization), { 'stream-auth-type':
|
|
11046
|
+
return Object.assign(Object.assign(Object.assign({ params: Object.assign({ user_id: this.userID, connection_id: this._getConnectionID(), api_key: this.key }, options.params), headers: Object.assign(Object.assign(Object.assign({}, authorization), { 'stream-auth-type': options.publicEndpoint && !this.user
|
|
11047
|
+
? 'anonymous'
|
|
11048
|
+
: this.getAuthType(), 'X-Stream-Client': this.getUserAgent() }), options.headers) }, (signal ? { signal } : {})), options.config), this.options.axiosRequestConfig);
|
|
11030
11049
|
}
|
|
11031
11050
|
_getToken() {
|
|
11032
11051
|
if (!this.tokenManager)
|
|
@@ -11043,7 +11062,7 @@ class StreamClient {
|
|
|
11043
11062
|
* createToken - Creates a token to authenticate this user. This function is used server side.
|
|
11044
11063
|
* The resulting token should be passed to the client side when the users registers or logs in.
|
|
11045
11064
|
*
|
|
11046
|
-
* @param {string} userID The
|
|
11065
|
+
* @param {string} userID The UserWithId ID
|
|
11047
11066
|
* @param {number} [exp] The expiration time for the token expressed in the number of seconds since the epoch
|
|
11048
11067
|
* @param call_cids for anonymous tokens you have to provide the call cids the use can join
|
|
11049
11068
|
*
|
|
@@ -11078,108 +11097,6 @@ class StreamVideoClient {
|
|
|
11078
11097
|
*/
|
|
11079
11098
|
constructor(apiKey, opts) {
|
|
11080
11099
|
this.eventHandlersToUnregister = [];
|
|
11081
|
-
/**
|
|
11082
|
-
* Connects the given user to the client.
|
|
11083
|
-
* Only one user can connect at a time, if you want to change users, call `disconnectUser` before connecting a new user.
|
|
11084
|
-
* If the connection is successful, the connected user [state variable](#readonlystatestore) will be updated accordingly.
|
|
11085
|
-
*
|
|
11086
|
-
* @param user the user to connect.
|
|
11087
|
-
* @param tokenOrProvider a token or a function that returns a token.
|
|
11088
|
-
*/
|
|
11089
|
-
this.connectUser = (user, tokenOrProvider) => __awaiter(this, void 0, void 0, function* () {
|
|
11090
|
-
var _a;
|
|
11091
|
-
const connectUser = () => {
|
|
11092
|
-
return this.streamClient.connectUser(
|
|
11093
|
-
// @ts-expect-error
|
|
11094
|
-
user, tokenOrProvider);
|
|
11095
|
-
};
|
|
11096
|
-
this.connectionPromise = this.disconnectionPromise
|
|
11097
|
-
? this.disconnectionPromise.then(() => connectUser())
|
|
11098
|
-
: connectUser();
|
|
11099
|
-
(_a = this.connectionPromise) === null || _a === void 0 ? void 0 : _a.finally(() => (this.connectionPromise = undefined));
|
|
11100
|
-
const connectUserResponse = yield this.connectionPromise;
|
|
11101
|
-
this.writeableStateStore.setConnectedUser(user);
|
|
11102
|
-
this.eventHandlersToUnregister.push(this.on('connection.changed', (e) => {
|
|
11103
|
-
const event = e;
|
|
11104
|
-
if (event.online) {
|
|
11105
|
-
const callsToReWatch = this.writeableStateStore.calls
|
|
11106
|
-
.filter((call) => call.watching)
|
|
11107
|
-
.map((call) => call.cid);
|
|
11108
|
-
if (callsToReWatch.length > 0) {
|
|
11109
|
-
this.queryCalls({
|
|
11110
|
-
watch: true,
|
|
11111
|
-
filter_conditions: {
|
|
11112
|
-
cid: { $in: callsToReWatch },
|
|
11113
|
-
},
|
|
11114
|
-
sort: [{ field: 'cid', direction: 1 }],
|
|
11115
|
-
}).catch((err) => {
|
|
11116
|
-
console.warn('Failed to re-watch calls', err);
|
|
11117
|
-
});
|
|
11118
|
-
}
|
|
11119
|
-
}
|
|
11120
|
-
}));
|
|
11121
|
-
this.eventHandlersToUnregister.push(this.on('call.created', (event) => {
|
|
11122
|
-
if (event.type !== 'call.created')
|
|
11123
|
-
return;
|
|
11124
|
-
const { call, members } = event;
|
|
11125
|
-
if (user.id === call.created_by.id) {
|
|
11126
|
-
console.warn('Received `call.created` sent by the current user');
|
|
11127
|
-
return;
|
|
11128
|
-
}
|
|
11129
|
-
this.writeableStateStore.registerCall(new Call({
|
|
11130
|
-
streamClient: this.streamClient,
|
|
11131
|
-
type: call.type,
|
|
11132
|
-
id: call.id,
|
|
11133
|
-
metadata: call,
|
|
11134
|
-
members,
|
|
11135
|
-
clientStore: this.writeableStateStore,
|
|
11136
|
-
}));
|
|
11137
|
-
}));
|
|
11138
|
-
this.eventHandlersToUnregister.push(this.on('call.ring', (event) => __awaiter(this, void 0, void 0, function* () {
|
|
11139
|
-
if (event.type !== 'call.ring')
|
|
11140
|
-
return;
|
|
11141
|
-
const { call, members } = event;
|
|
11142
|
-
if (user.id === call.created_by.id) {
|
|
11143
|
-
console.warn('Received `call.ring` sent by the current user');
|
|
11144
|
-
return;
|
|
11145
|
-
}
|
|
11146
|
-
// The call might already be tracked by the client,
|
|
11147
|
-
// if `call.created` was received before `call.ring`.
|
|
11148
|
-
// In that case, we just reuse the already tracked call.
|
|
11149
|
-
let theCall = this.writeableStateStore.findCall(call.type, call.id);
|
|
11150
|
-
if (!theCall) {
|
|
11151
|
-
// otherwise, we create a new call
|
|
11152
|
-
theCall = new Call({
|
|
11153
|
-
streamClient: this.streamClient,
|
|
11154
|
-
type: call.type,
|
|
11155
|
-
id: call.id,
|
|
11156
|
-
members,
|
|
11157
|
-
clientStore: this.writeableStateStore,
|
|
11158
|
-
ringing: true,
|
|
11159
|
-
});
|
|
11160
|
-
}
|
|
11161
|
-
// we fetch the latest metadata for the call from the server
|
|
11162
|
-
yield theCall.get({ ring: true });
|
|
11163
|
-
this.writeableStateStore.registerCall(theCall);
|
|
11164
|
-
})));
|
|
11165
|
-
return connectUserResponse;
|
|
11166
|
-
});
|
|
11167
|
-
/**
|
|
11168
|
-
* Connects the given anonymous user to the client.
|
|
11169
|
-
*
|
|
11170
|
-
* @param user the user to connect.
|
|
11171
|
-
* @param tokenOrProvider a token or a function that returns a token.
|
|
11172
|
-
*/
|
|
11173
|
-
this.connectAnonymousUser = (user, tokenOrProvider) => __awaiter(this, void 0, void 0, function* () {
|
|
11174
|
-
const connectAnonymousUser = () =>
|
|
11175
|
-
// @ts-expect-error
|
|
11176
|
-
this.streamClient.connectAnonymousUser(user, tokenOrProvider);
|
|
11177
|
-
this.connectionPromise = this.disconnectionPromise
|
|
11178
|
-
? this.disconnectionPromise.then(() => connectAnonymousUser())
|
|
11179
|
-
: connectAnonymousUser();
|
|
11180
|
-
this.connectionPromise.finally(() => (this.connectionPromise = undefined));
|
|
11181
|
-
return this.connectionPromise;
|
|
11182
|
-
});
|
|
11183
11100
|
/**
|
|
11184
11101
|
* Disconnects the currently connected user from the client.
|
|
11185
11102
|
*
|
|
@@ -11240,7 +11157,7 @@ class StreamVideoClient {
|
|
|
11240
11157
|
* @param data the data for the guest user.
|
|
11241
11158
|
*/
|
|
11242
11159
|
this.createGuestUser = (data) => __awaiter(this, void 0, void 0, function* () {
|
|
11243
|
-
return this.streamClient.
|
|
11160
|
+
return this.streamClient.doAxiosRequest('post', '/guest', data, { publicEndpoint: true });
|
|
11244
11161
|
});
|
|
11245
11162
|
/**
|
|
11246
11163
|
* Will query the API for calls matching the given filters.
|
|
@@ -11321,10 +11238,123 @@ class StreamVideoClient {
|
|
|
11321
11238
|
this.removeDevice = (id, userID) => __awaiter(this, void 0, void 0, function* () {
|
|
11322
11239
|
return yield this.streamClient.delete('/devices', Object.assign({ id }, (userID ? { user_id: userID } : {})));
|
|
11323
11240
|
});
|
|
11241
|
+
/**
|
|
11242
|
+
* Connects the given anonymous user to the client.
|
|
11243
|
+
*
|
|
11244
|
+
* @param user the user to connect.
|
|
11245
|
+
* @param tokenOrProvider a token or a function that returns a token.
|
|
11246
|
+
*/
|
|
11247
|
+
this.connectAnonymousUser = (user, tokenOrProvider) => __awaiter(this, void 0, void 0, function* () {
|
|
11248
|
+
const connectAnonymousUser = () => this.streamClient.connectAnonymousUser(user, tokenOrProvider);
|
|
11249
|
+
this.connectionPromise = this.disconnectionPromise
|
|
11250
|
+
? this.disconnectionPromise.then(() => connectAnonymousUser())
|
|
11251
|
+
: connectAnonymousUser();
|
|
11252
|
+
this.connectionPromise.finally(() => (this.connectionPromise = undefined));
|
|
11253
|
+
return this.connectionPromise;
|
|
11254
|
+
});
|
|
11324
11255
|
this.streamClient = new StreamClient(apiKey, Object.assign({ persistUserOnConnectionFailure: true }, opts));
|
|
11325
11256
|
this.writeableStateStore = new StreamVideoWriteableStateStore();
|
|
11326
11257
|
this.readOnlyStateStore = new StreamVideoReadOnlyStateStore(this.writeableStateStore);
|
|
11327
11258
|
}
|
|
11259
|
+
/**
|
|
11260
|
+
* Connects the given user to the client.
|
|
11261
|
+
* Only one user can connect at a time, if you want to change users, call `disconnectUser` before connecting a new user.
|
|
11262
|
+
* If the connection is successful, the connected user [state variable](#readonlystatestore) will be updated accordingly.
|
|
11263
|
+
*
|
|
11264
|
+
* @param user the user to connect.
|
|
11265
|
+
* @param tokenOrProvider a token or a function that returns a token.
|
|
11266
|
+
*/
|
|
11267
|
+
connectUser(user, token) {
|
|
11268
|
+
var _a;
|
|
11269
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
11270
|
+
if (user.type === 'anonymous') {
|
|
11271
|
+
user.id = '!anon';
|
|
11272
|
+
return this.connectAnonymousUser(user, token);
|
|
11273
|
+
}
|
|
11274
|
+
if (user.type === 'guest') {
|
|
11275
|
+
const response = yield this.createGuestUser({
|
|
11276
|
+
user: Object.assign(Object.assign({}, user), { role: 'guest' }),
|
|
11277
|
+
});
|
|
11278
|
+
return this.connectUser(response.user, response.access_token);
|
|
11279
|
+
}
|
|
11280
|
+
const connectUser = () => {
|
|
11281
|
+
return this.streamClient.connectUser(user, token);
|
|
11282
|
+
};
|
|
11283
|
+
this.connectionPromise = this.disconnectionPromise
|
|
11284
|
+
? this.disconnectionPromise.then(() => connectUser())
|
|
11285
|
+
: connectUser();
|
|
11286
|
+
(_a = this.connectionPromise) === null || _a === void 0 ? void 0 : _a.finally(() => (this.connectionPromise = undefined));
|
|
11287
|
+
const connectUserResponse = yield this.connectionPromise;
|
|
11288
|
+
// connectUserResponse will be void if connectUser called twice for the same user
|
|
11289
|
+
if (connectUserResponse === null || connectUserResponse === void 0 ? void 0 : connectUserResponse.me) {
|
|
11290
|
+
this.writeableStateStore.setConnectedUser(connectUserResponse.me);
|
|
11291
|
+
}
|
|
11292
|
+
this.eventHandlersToUnregister.push(this.on('connection.changed', (e) => {
|
|
11293
|
+
const event = e;
|
|
11294
|
+
if (event.online) {
|
|
11295
|
+
const callsToReWatch = this.writeableStateStore.calls
|
|
11296
|
+
.filter((call) => call.watching)
|
|
11297
|
+
.map((call) => call.cid);
|
|
11298
|
+
if (callsToReWatch.length > 0) {
|
|
11299
|
+
this.queryCalls({
|
|
11300
|
+
watch: true,
|
|
11301
|
+
filter_conditions: {
|
|
11302
|
+
cid: { $in: callsToReWatch },
|
|
11303
|
+
},
|
|
11304
|
+
sort: [{ field: 'cid', direction: 1 }],
|
|
11305
|
+
}).catch((err) => {
|
|
11306
|
+
console.warn('Failed to re-watch calls', err);
|
|
11307
|
+
});
|
|
11308
|
+
}
|
|
11309
|
+
}
|
|
11310
|
+
}));
|
|
11311
|
+
this.eventHandlersToUnregister.push(this.on('call.created', (event) => {
|
|
11312
|
+
if (event.type !== 'call.created')
|
|
11313
|
+
return;
|
|
11314
|
+
const { call, members } = event;
|
|
11315
|
+
if (user.id === call.created_by.id) {
|
|
11316
|
+
console.warn('Received `call.created` sent by the current user');
|
|
11317
|
+
return;
|
|
11318
|
+
}
|
|
11319
|
+
this.writeableStateStore.registerCall(new Call({
|
|
11320
|
+
streamClient: this.streamClient,
|
|
11321
|
+
type: call.type,
|
|
11322
|
+
id: call.id,
|
|
11323
|
+
metadata: call,
|
|
11324
|
+
members,
|
|
11325
|
+
clientStore: this.writeableStateStore,
|
|
11326
|
+
}));
|
|
11327
|
+
}));
|
|
11328
|
+
this.eventHandlersToUnregister.push(this.on('call.ring', (event) => __awaiter(this, void 0, void 0, function* () {
|
|
11329
|
+
if (event.type !== 'call.ring')
|
|
11330
|
+
return;
|
|
11331
|
+
const { call, members } = event;
|
|
11332
|
+
if (user.id === call.created_by.id) {
|
|
11333
|
+
console.warn('Received `call.ring` sent by the current user');
|
|
11334
|
+
return;
|
|
11335
|
+
}
|
|
11336
|
+
// The call might already be tracked by the client,
|
|
11337
|
+
// if `call.created` was received before `call.ring`.
|
|
11338
|
+
// In that case, we just reuse the already tracked call.
|
|
11339
|
+
let theCall = this.writeableStateStore.findCall(call.type, call.id);
|
|
11340
|
+
if (!theCall) {
|
|
11341
|
+
// otherwise, we create a new call
|
|
11342
|
+
theCall = new Call({
|
|
11343
|
+
streamClient: this.streamClient,
|
|
11344
|
+
type: call.type,
|
|
11345
|
+
id: call.id,
|
|
11346
|
+
members,
|
|
11347
|
+
clientStore: this.writeableStateStore,
|
|
11348
|
+
ringing: true,
|
|
11349
|
+
});
|
|
11350
|
+
}
|
|
11351
|
+
// we fetch the latest metadata for the call from the server
|
|
11352
|
+
yield theCall.get({ ring: true });
|
|
11353
|
+
this.writeableStateStore.registerCall(theCall);
|
|
11354
|
+
})));
|
|
11355
|
+
return connectUserResponse;
|
|
11356
|
+
});
|
|
11357
|
+
}
|
|
11328
11358
|
/**
|
|
11329
11359
|
* addDevice - Adds a push device for a user.
|
|
11330
11360
|
*
|