@coze/realtime-api 1.0.5-alpha.126a93 → 1.0.5-alpha.feed0d
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/cjs/index.cjs +28 -7
- package/dist/esm/index.js +28 -7
- package/dist/types/client.d.ts +2 -1
- package/dist/types/event-handler.d.ts +11 -1
- package/dist/umd/index.js +28 -7
- package/package.json +1 -2
package/dist/cjs/index.cjs
CHANGED
@@ -39488,6 +39488,10 @@ var event_handler_EventNames = /*#__PURE__*/ function(EventNames) {
|
|
39488
39488
|
* zh: 客户端连接
|
39489
39489
|
*/ EventNames["CONNECTED"] = "client.connected";
|
39490
39490
|
/**
|
39491
|
+
* en: Client connecting
|
39492
|
+
* zh: 客户端连接中
|
39493
|
+
*/ EventNames["CONNECTING"] = "client.connecting";
|
39494
|
+
/**
|
39491
39495
|
* en: Client interrupted
|
39492
39496
|
* zh: 客户端中断
|
39493
39497
|
*/ EventNames["INTERRUPTED"] = "client.interrupted";
|
@@ -39540,6 +39544,10 @@ var event_handler_EventNames = /*#__PURE__*/ function(EventNames) {
|
|
39540
39544
|
* zh: 视频输入设备改变
|
39541
39545
|
*/ EventNames["VIDEO_INPUT_DEVICE_CHANGED"] = "client.video.input.device.changed";
|
39542
39546
|
/**
|
39547
|
+
* en: Network quality changed
|
39548
|
+
* zh: 网络质量改变
|
39549
|
+
*/ EventNames["NETWORK_QUALITY"] = "client.network.quality";
|
39550
|
+
/**
|
39543
39551
|
* en: Bot joined
|
39544
39552
|
* zh: Bot 加入
|
39545
39553
|
*/ EventNames["BOT_JOIN"] = "server.bot.join";
|
@@ -39592,7 +39600,10 @@ class RealtimeEventHandler {
|
|
39592
39600
|
const handlers = this.eventHandlers[eventName] || [];
|
39593
39601
|
if (callback) {
|
39594
39602
|
const index = handlers.indexOf(callback);
|
39595
|
-
if (-1 === index)
|
39603
|
+
if (-1 === index) {
|
39604
|
+
console.warn(`Could not turn off specified event listener for "${eventName}": not found as a listener`);
|
39605
|
+
return;
|
39606
|
+
}
|
39596
39607
|
handlers.splice(index, 1);
|
39597
39608
|
} else delete this.eventHandlers[eventName];
|
39598
39609
|
}
|
@@ -39606,7 +39617,7 @@ class RealtimeEventHandler {
|
|
39606
39617
|
}
|
39607
39618
|
dispatch(eventName, event) {
|
39608
39619
|
let consoleLog = !(arguments.length > 2) || void 0 === arguments[2] || arguments[2];
|
39609
|
-
if (consoleLog) this._log(`dispatch ${eventName} event
|
39620
|
+
if (consoleLog) this._log(`dispatch ${eventName} event`, event);
|
39610
39621
|
const handlers = (this.eventHandlers[eventName] || []).slice();
|
39611
39622
|
this._dispatchToHandlers(eventName, event, handlers);
|
39612
39623
|
const allHandlers = (this.eventHandlers["realtime.event"] || []).slice();
|
@@ -39616,8 +39627,8 @@ class RealtimeEventHandler {
|
|
39616
39627
|
const allServerHandlers = (this.eventHandlers["server.*"] || []).slice();
|
39617
39628
|
this._dispatchToHandlers(eventName, event, allServerHandlers, 'server.');
|
39618
39629
|
}
|
39619
|
-
_log(message) {
|
39620
|
-
if (this._debug) console.log(`[RealtimeClient] ${message}
|
39630
|
+
_log(message, event) {
|
39631
|
+
if (this._debug) console.log(`[RealtimeClient] ${message}`, event);
|
39621
39632
|
}
|
39622
39633
|
constructor(debug = false){
|
39623
39634
|
this.eventHandlers = {};
|
@@ -42875,6 +42886,7 @@ class EngineClient extends RealtimeEventHandler {
|
|
42875
42886
|
this.engine.on(index_esm_min_index.events.onUserJoined, this.handleUserJoin);
|
42876
42887
|
this.engine.on(index_esm_min_index.events.onUserLeave, this.handleUserLeave);
|
42877
42888
|
this.engine.on(index_esm_min_index.events.onError, this.handleEventError);
|
42889
|
+
this.engine.on(index_esm_min_index.events.onNetworkQuality, this.handleNetworkQuality);
|
42878
42890
|
if (this._isSupportVideo) this.engine.on(index_esm_min_index.events.onPlayerEvent, this.handlePlayerEvent);
|
42879
42891
|
if (this._debug) {
|
42880
42892
|
this.engine.on(index_esm_min_index.events.onLocalAudioPropertiesReport, this.handleLocalAudioPropertiesReport);
|
@@ -42886,6 +42898,7 @@ class EngineClient extends RealtimeEventHandler {
|
|
42886
42898
|
this.engine.off(index_esm_min_index.events.onUserJoined, this.handleUserJoin);
|
42887
42899
|
this.engine.off(index_esm_min_index.events.onUserLeave, this.handleUserLeave);
|
42888
42900
|
this.engine.off(index_esm_min_index.events.onError, this.handleEventError);
|
42901
|
+
this.engine.off(index_esm_min_index.events.onNetworkQuality, this.handleNetworkQuality);
|
42889
42902
|
if (this._isSupportVideo) this.engine.off(index_esm_min_index.events.onPlayerEvent, this.handlePlayerEvent);
|
42890
42903
|
if (this._debug) {
|
42891
42904
|
this.engine.off(index_esm_min_index.events.onLocalAudioPropertiesReport, this.handleLocalAudioPropertiesReport);
|
@@ -42930,6 +42943,12 @@ class EngineClient extends RealtimeEventHandler {
|
|
42930
42943
|
handlePlayerEvent(event) {
|
42931
42944
|
this.dispatch(event_handler_EventNames.PLAYER_EVENT, event);
|
42932
42945
|
}
|
42946
|
+
handleNetworkQuality(uplinkNetworkQuality, downlinkNetworkQuality) {
|
42947
|
+
this.dispatch(event_handler_EventNames.NETWORK_QUALITY, {
|
42948
|
+
uplinkNetworkQuality,
|
42949
|
+
downlinkNetworkQuality
|
42950
|
+
});
|
42951
|
+
}
|
42933
42952
|
async joinRoom(options) {
|
42934
42953
|
const { token, roomId, uid, audioMutedDefault, videoOnDefault, isAutoSubscribeAudio } = options;
|
42935
42954
|
try {
|
@@ -42996,11 +43015,10 @@ class EngineClient extends RealtimeEventHandler {
|
|
42996
43015
|
}
|
42997
43016
|
async disconnect() {
|
42998
43017
|
try {
|
42999
|
-
if (this._isSupportVideo) await this.changeVideoState(false);
|
43000
|
-
await this.changeAudioState(false);
|
43001
|
-
await this.engine.unpublishStream(MediaType$1.AUDIO);
|
43002
43018
|
await this.engine.leaveRoom();
|
43003
43019
|
this.removeEventListener();
|
43020
|
+
this.clearEventHandlers();
|
43021
|
+
index_esm_min_index.destroyEngine(this.engine);
|
43004
43022
|
} catch (e) {
|
43005
43023
|
this.dispatch(event_handler_EventNames.ERROR, e);
|
43006
43024
|
throw e;
|
@@ -43121,6 +43139,7 @@ class EngineClient extends RealtimeEventHandler {
|
|
43121
43139
|
this.handleUserLeave = this.handleUserLeave.bind(this);
|
43122
43140
|
this.handleEventError = this.handleEventError.bind(this);
|
43123
43141
|
this.handlePlayerEvent = this.handlePlayerEvent.bind(this);
|
43142
|
+
this.handleNetworkQuality = this.handleNetworkQuality.bind(this);
|
43124
43143
|
// Debug only
|
43125
43144
|
this.handleLocalAudioPropertiesReport = this.handleLocalAudioPropertiesReport.bind(this);
|
43126
43145
|
this.handleRemoteAudioPropertiesReport = this.handleRemoteAudioPropertiesReport.bind(this);
|
@@ -43136,6 +43155,7 @@ class RealtimeClient extends RealtimeEventHandler {
|
|
43136
43155
|
*/ async connect() {
|
43137
43156
|
var _this__config_videoConfig;
|
43138
43157
|
const { botId, conversationId, voiceId } = this._config;
|
43158
|
+
this.dispatch(event_handler_EventNames.CONNECTING, {});
|
43139
43159
|
let roomInfo;
|
43140
43160
|
try {
|
43141
43161
|
// Step1 get token
|
@@ -43216,6 +43236,7 @@ class RealtimeClient extends RealtimeEventHandler {
|
|
43216
43236
|
var _this__client;
|
43217
43237
|
await (null === (_this__client = this._client) || void 0 === _this__client ? void 0 : _this__client.disconnect());
|
43218
43238
|
this.isConnected = false;
|
43239
|
+
this._client = null;
|
43219
43240
|
this.dispatch(event_handler_EventNames.DISCONNECTED, {});
|
43220
43241
|
}
|
43221
43242
|
/**
|
package/dist/esm/index.js
CHANGED
@@ -39476,6 +39476,10 @@ var event_handler_EventNames = /*#__PURE__*/ function(EventNames) {
|
|
39476
39476
|
* zh: 客户端连接
|
39477
39477
|
*/ EventNames["CONNECTED"] = "client.connected";
|
39478
39478
|
/**
|
39479
|
+
* en: Client connecting
|
39480
|
+
* zh: 客户端连接中
|
39481
|
+
*/ EventNames["CONNECTING"] = "client.connecting";
|
39482
|
+
/**
|
39479
39483
|
* en: Client interrupted
|
39480
39484
|
* zh: 客户端中断
|
39481
39485
|
*/ EventNames["INTERRUPTED"] = "client.interrupted";
|
@@ -39528,6 +39532,10 @@ var event_handler_EventNames = /*#__PURE__*/ function(EventNames) {
|
|
39528
39532
|
* zh: 视频输入设备改变
|
39529
39533
|
*/ EventNames["VIDEO_INPUT_DEVICE_CHANGED"] = "client.video.input.device.changed";
|
39530
39534
|
/**
|
39535
|
+
* en: Network quality changed
|
39536
|
+
* zh: 网络质量改变
|
39537
|
+
*/ EventNames["NETWORK_QUALITY"] = "client.network.quality";
|
39538
|
+
/**
|
39531
39539
|
* en: Bot joined
|
39532
39540
|
* zh: Bot 加入
|
39533
39541
|
*/ EventNames["BOT_JOIN"] = "server.bot.join";
|
@@ -39580,7 +39588,10 @@ class RealtimeEventHandler {
|
|
39580
39588
|
const handlers = this.eventHandlers[eventName] || [];
|
39581
39589
|
if (callback) {
|
39582
39590
|
const index = handlers.indexOf(callback);
|
39583
|
-
if (-1 === index)
|
39591
|
+
if (-1 === index) {
|
39592
|
+
console.warn(`Could not turn off specified event listener for "${eventName}": not found as a listener`);
|
39593
|
+
return;
|
39594
|
+
}
|
39584
39595
|
handlers.splice(index, 1);
|
39585
39596
|
} else delete this.eventHandlers[eventName];
|
39586
39597
|
}
|
@@ -39594,7 +39605,7 @@ class RealtimeEventHandler {
|
|
39594
39605
|
}
|
39595
39606
|
dispatch(eventName, event) {
|
39596
39607
|
let consoleLog = !(arguments.length > 2) || void 0 === arguments[2] || arguments[2];
|
39597
|
-
if (consoleLog) this._log(`dispatch ${eventName} event
|
39608
|
+
if (consoleLog) this._log(`dispatch ${eventName} event`, event);
|
39598
39609
|
const handlers = (this.eventHandlers[eventName] || []).slice();
|
39599
39610
|
this._dispatchToHandlers(eventName, event, handlers);
|
39600
39611
|
const allHandlers = (this.eventHandlers["realtime.event"] || []).slice();
|
@@ -39604,8 +39615,8 @@ class RealtimeEventHandler {
|
|
39604
39615
|
const allServerHandlers = (this.eventHandlers["server.*"] || []).slice();
|
39605
39616
|
this._dispatchToHandlers(eventName, event, allServerHandlers, 'server.');
|
39606
39617
|
}
|
39607
|
-
_log(message) {
|
39608
|
-
if (this._debug) console.log(`[RealtimeClient] ${message}
|
39618
|
+
_log(message, event) {
|
39619
|
+
if (this._debug) console.log(`[RealtimeClient] ${message}`, event);
|
39609
39620
|
}
|
39610
39621
|
constructor(debug = false){
|
39611
39622
|
this.eventHandlers = {};
|
@@ -42863,6 +42874,7 @@ class EngineClient extends RealtimeEventHandler {
|
|
42863
42874
|
this.engine.on(index_esm_min_index.events.onUserJoined, this.handleUserJoin);
|
42864
42875
|
this.engine.on(index_esm_min_index.events.onUserLeave, this.handleUserLeave);
|
42865
42876
|
this.engine.on(index_esm_min_index.events.onError, this.handleEventError);
|
42877
|
+
this.engine.on(index_esm_min_index.events.onNetworkQuality, this.handleNetworkQuality);
|
42866
42878
|
if (this._isSupportVideo) this.engine.on(index_esm_min_index.events.onPlayerEvent, this.handlePlayerEvent);
|
42867
42879
|
if (this._debug) {
|
42868
42880
|
this.engine.on(index_esm_min_index.events.onLocalAudioPropertiesReport, this.handleLocalAudioPropertiesReport);
|
@@ -42874,6 +42886,7 @@ class EngineClient extends RealtimeEventHandler {
|
|
42874
42886
|
this.engine.off(index_esm_min_index.events.onUserJoined, this.handleUserJoin);
|
42875
42887
|
this.engine.off(index_esm_min_index.events.onUserLeave, this.handleUserLeave);
|
42876
42888
|
this.engine.off(index_esm_min_index.events.onError, this.handleEventError);
|
42889
|
+
this.engine.off(index_esm_min_index.events.onNetworkQuality, this.handleNetworkQuality);
|
42877
42890
|
if (this._isSupportVideo) this.engine.off(index_esm_min_index.events.onPlayerEvent, this.handlePlayerEvent);
|
42878
42891
|
if (this._debug) {
|
42879
42892
|
this.engine.off(index_esm_min_index.events.onLocalAudioPropertiesReport, this.handleLocalAudioPropertiesReport);
|
@@ -42918,6 +42931,12 @@ class EngineClient extends RealtimeEventHandler {
|
|
42918
42931
|
handlePlayerEvent(event) {
|
42919
42932
|
this.dispatch(event_handler_EventNames.PLAYER_EVENT, event);
|
42920
42933
|
}
|
42934
|
+
handleNetworkQuality(uplinkNetworkQuality, downlinkNetworkQuality) {
|
42935
|
+
this.dispatch(event_handler_EventNames.NETWORK_QUALITY, {
|
42936
|
+
uplinkNetworkQuality,
|
42937
|
+
downlinkNetworkQuality
|
42938
|
+
});
|
42939
|
+
}
|
42921
42940
|
async joinRoom(options) {
|
42922
42941
|
const { token, roomId, uid, audioMutedDefault, videoOnDefault, isAutoSubscribeAudio } = options;
|
42923
42942
|
try {
|
@@ -42984,11 +43003,10 @@ class EngineClient extends RealtimeEventHandler {
|
|
42984
43003
|
}
|
42985
43004
|
async disconnect() {
|
42986
43005
|
try {
|
42987
|
-
if (this._isSupportVideo) await this.changeVideoState(false);
|
42988
|
-
await this.changeAudioState(false);
|
42989
|
-
await this.engine.unpublishStream(MediaType$1.AUDIO);
|
42990
43006
|
await this.engine.leaveRoom();
|
42991
43007
|
this.removeEventListener();
|
43008
|
+
this.clearEventHandlers();
|
43009
|
+
index_esm_min_index.destroyEngine(this.engine);
|
42992
43010
|
} catch (e) {
|
42993
43011
|
this.dispatch(event_handler_EventNames.ERROR, e);
|
42994
43012
|
throw e;
|
@@ -43109,6 +43127,7 @@ class EngineClient extends RealtimeEventHandler {
|
|
43109
43127
|
this.handleUserLeave = this.handleUserLeave.bind(this);
|
43110
43128
|
this.handleEventError = this.handleEventError.bind(this);
|
43111
43129
|
this.handlePlayerEvent = this.handlePlayerEvent.bind(this);
|
43130
|
+
this.handleNetworkQuality = this.handleNetworkQuality.bind(this);
|
43112
43131
|
// Debug only
|
43113
43132
|
this.handleLocalAudioPropertiesReport = this.handleLocalAudioPropertiesReport.bind(this);
|
43114
43133
|
this.handleRemoteAudioPropertiesReport = this.handleRemoteAudioPropertiesReport.bind(this);
|
@@ -43124,6 +43143,7 @@ class RealtimeClient extends RealtimeEventHandler {
|
|
43124
43143
|
*/ async connect() {
|
43125
43144
|
var _this__config_videoConfig;
|
43126
43145
|
const { botId, conversationId, voiceId } = this._config;
|
43146
|
+
this.dispatch(event_handler_EventNames.CONNECTING, {});
|
43127
43147
|
let roomInfo;
|
43128
43148
|
try {
|
43129
43149
|
// Step1 get token
|
@@ -43204,6 +43224,7 @@ class RealtimeClient extends RealtimeEventHandler {
|
|
43204
43224
|
var _this__client;
|
43205
43225
|
await (null === (_this__client = this._client) || void 0 === _this__client ? void 0 : _this__client.disconnect());
|
43206
43226
|
this.isConnected = false;
|
43227
|
+
this._client = null;
|
43207
43228
|
this.dispatch(event_handler_EventNames.DISCONNECTED, {});
|
43208
43229
|
}
|
43209
43230
|
/**
|
package/dist/types/client.d.ts
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
import { type AudioPropertiesConfig, type IRTCEngine, type onUserJoinedEvent, type onUserLeaveEvent, type UserMessageEvent } from '@volcengine/rtc';
|
1
|
+
import { type AudioPropertiesConfig, type IRTCEngine, type NetworkQuality, type onUserJoinedEvent, type onUserLeaveEvent, type UserMessageEvent } from '@volcengine/rtc';
|
2
2
|
import { RealtimeEventHandler } from './event-handler';
|
3
3
|
import { type VideoConfig } from '.';
|
4
4
|
export declare class EngineClient extends RealtimeEventHandler {
|
@@ -18,6 +18,7 @@ export declare class EngineClient extends RealtimeEventHandler {
|
|
18
18
|
handleUserJoin(event: onUserJoinedEvent): void;
|
19
19
|
handleUserLeave(event: onUserLeaveEvent): void;
|
20
20
|
handlePlayerEvent(event: unknown): void;
|
21
|
+
handleNetworkQuality(uplinkNetworkQuality: NetworkQuality, downlinkNetworkQuality: NetworkQuality): void;
|
21
22
|
joinRoom(options: {
|
22
23
|
token: string;
|
23
24
|
roomId: string;
|
@@ -19,6 +19,11 @@ export declare enum EventNames {
|
|
19
19
|
* zh: 客户端连接
|
20
20
|
*/
|
21
21
|
CONNECTED = "client.connected",
|
22
|
+
/**
|
23
|
+
* en: Client connecting
|
24
|
+
* zh: 客户端连接中
|
25
|
+
*/
|
26
|
+
CONNECTING = "client.connecting",
|
22
27
|
/**
|
23
28
|
* en: Client interrupted
|
24
29
|
* zh: 客户端中断
|
@@ -84,6 +89,11 @@ export declare enum EventNames {
|
|
84
89
|
* zh: 视频输入设备改变
|
85
90
|
*/
|
86
91
|
VIDEO_INPUT_DEVICE_CHANGED = "client.video.input.device.changed",
|
92
|
+
/**
|
93
|
+
* en: Network quality changed
|
94
|
+
* zh: 网络质量改变
|
95
|
+
*/
|
96
|
+
NETWORK_QUALITY = "client.network.quality",
|
87
97
|
/**
|
88
98
|
* en: Bot joined
|
89
99
|
* zh: Bot 加入
|
@@ -140,5 +150,5 @@ export declare class RealtimeEventHandler {
|
|
140
150
|
off(eventName: string, callback: EventCallback): void;
|
141
151
|
private _dispatchToHandlers;
|
142
152
|
dispatch(eventName: string, event: unknown, consoleLog?: boolean): void;
|
143
|
-
_log(message: string): void;
|
153
|
+
_log(message: string, event?: unknown): void;
|
144
154
|
}
|
package/dist/umd/index.js
CHANGED
@@ -39494,6 +39494,10 @@ and limitations under the License.
|
|
39494
39494
|
* zh: 客户端连接
|
39495
39495
|
*/ EventNames["CONNECTED"] = "client.connected";
|
39496
39496
|
/**
|
39497
|
+
* en: Client connecting
|
39498
|
+
* zh: 客户端连接中
|
39499
|
+
*/ EventNames["CONNECTING"] = "client.connecting";
|
39500
|
+
/**
|
39497
39501
|
* en: Client interrupted
|
39498
39502
|
* zh: 客户端中断
|
39499
39503
|
*/ EventNames["INTERRUPTED"] = "client.interrupted";
|
@@ -39546,6 +39550,10 @@ and limitations under the License.
|
|
39546
39550
|
* zh: 视频输入设备改变
|
39547
39551
|
*/ EventNames["VIDEO_INPUT_DEVICE_CHANGED"] = "client.video.input.device.changed";
|
39548
39552
|
/**
|
39553
|
+
* en: Network quality changed
|
39554
|
+
* zh: 网络质量改变
|
39555
|
+
*/ EventNames["NETWORK_QUALITY"] = "client.network.quality";
|
39556
|
+
/**
|
39549
39557
|
* en: Bot joined
|
39550
39558
|
* zh: Bot 加入
|
39551
39559
|
*/ EventNames["BOT_JOIN"] = "server.bot.join";
|
@@ -39598,7 +39606,10 @@ and limitations under the License.
|
|
39598
39606
|
const handlers = this.eventHandlers[eventName] || [];
|
39599
39607
|
if (callback) {
|
39600
39608
|
const index = handlers.indexOf(callback);
|
39601
|
-
if (-1 === index)
|
39609
|
+
if (-1 === index) {
|
39610
|
+
console.warn(`Could not turn off specified event listener for "${eventName}": not found as a listener`);
|
39611
|
+
return;
|
39612
|
+
}
|
39602
39613
|
handlers.splice(index, 1);
|
39603
39614
|
} else delete this.eventHandlers[eventName];
|
39604
39615
|
}
|
@@ -39612,7 +39623,7 @@ and limitations under the License.
|
|
39612
39623
|
}
|
39613
39624
|
dispatch(eventName, event) {
|
39614
39625
|
let consoleLog = !(arguments.length > 2) || void 0 === arguments[2] || arguments[2];
|
39615
|
-
if (consoleLog) this._log(`dispatch ${eventName} event
|
39626
|
+
if (consoleLog) this._log(`dispatch ${eventName} event`, event);
|
39616
39627
|
const handlers = (this.eventHandlers[eventName] || []).slice();
|
39617
39628
|
this._dispatchToHandlers(eventName, event, handlers);
|
39618
39629
|
const allHandlers = (this.eventHandlers["realtime.event"] || []).slice();
|
@@ -39622,8 +39633,8 @@ and limitations under the License.
|
|
39622
39633
|
const allServerHandlers = (this.eventHandlers["server.*"] || []).slice();
|
39623
39634
|
this._dispatchToHandlers(eventName, event, allServerHandlers, 'server.');
|
39624
39635
|
}
|
39625
|
-
_log(message) {
|
39626
|
-
if (this._debug) console.log(`[RealtimeClient] ${message}
|
39636
|
+
_log(message, event) {
|
39637
|
+
if (this._debug) console.log(`[RealtimeClient] ${message}`, event);
|
39627
39638
|
}
|
39628
39639
|
constructor(debug = false){
|
39629
39640
|
this.eventHandlers = {};
|
@@ -42881,6 +42892,7 @@ and limitations under the License.
|
|
42881
42892
|
this.engine.on(index_esm_min_index.events.onUserJoined, this.handleUserJoin);
|
42882
42893
|
this.engine.on(index_esm_min_index.events.onUserLeave, this.handleUserLeave);
|
42883
42894
|
this.engine.on(index_esm_min_index.events.onError, this.handleEventError);
|
42895
|
+
this.engine.on(index_esm_min_index.events.onNetworkQuality, this.handleNetworkQuality);
|
42884
42896
|
if (this._isSupportVideo) this.engine.on(index_esm_min_index.events.onPlayerEvent, this.handlePlayerEvent);
|
42885
42897
|
if (this._debug) {
|
42886
42898
|
this.engine.on(index_esm_min_index.events.onLocalAudioPropertiesReport, this.handleLocalAudioPropertiesReport);
|
@@ -42892,6 +42904,7 @@ and limitations under the License.
|
|
42892
42904
|
this.engine.off(index_esm_min_index.events.onUserJoined, this.handleUserJoin);
|
42893
42905
|
this.engine.off(index_esm_min_index.events.onUserLeave, this.handleUserLeave);
|
42894
42906
|
this.engine.off(index_esm_min_index.events.onError, this.handleEventError);
|
42907
|
+
this.engine.off(index_esm_min_index.events.onNetworkQuality, this.handleNetworkQuality);
|
42895
42908
|
if (this._isSupportVideo) this.engine.off(index_esm_min_index.events.onPlayerEvent, this.handlePlayerEvent);
|
42896
42909
|
if (this._debug) {
|
42897
42910
|
this.engine.off(index_esm_min_index.events.onLocalAudioPropertiesReport, this.handleLocalAudioPropertiesReport);
|
@@ -42936,6 +42949,12 @@ and limitations under the License.
|
|
42936
42949
|
handlePlayerEvent(event) {
|
42937
42950
|
this.dispatch(event_handler_EventNames.PLAYER_EVENT, event);
|
42938
42951
|
}
|
42952
|
+
handleNetworkQuality(uplinkNetworkQuality, downlinkNetworkQuality) {
|
42953
|
+
this.dispatch(event_handler_EventNames.NETWORK_QUALITY, {
|
42954
|
+
uplinkNetworkQuality,
|
42955
|
+
downlinkNetworkQuality
|
42956
|
+
});
|
42957
|
+
}
|
42939
42958
|
async joinRoom(options) {
|
42940
42959
|
const { token, roomId, uid, audioMutedDefault, videoOnDefault, isAutoSubscribeAudio } = options;
|
42941
42960
|
try {
|
@@ -43002,11 +43021,10 @@ and limitations under the License.
|
|
43002
43021
|
}
|
43003
43022
|
async disconnect() {
|
43004
43023
|
try {
|
43005
|
-
if (this._isSupportVideo) await this.changeVideoState(false);
|
43006
|
-
await this.changeAudioState(false);
|
43007
|
-
await this.engine.unpublishStream(MediaType$1.AUDIO);
|
43008
43024
|
await this.engine.leaveRoom();
|
43009
43025
|
this.removeEventListener();
|
43026
|
+
this.clearEventHandlers();
|
43027
|
+
index_esm_min_index.destroyEngine(this.engine);
|
43010
43028
|
} catch (e) {
|
43011
43029
|
this.dispatch(event_handler_EventNames.ERROR, e);
|
43012
43030
|
throw e;
|
@@ -43127,6 +43145,7 @@ and limitations under the License.
|
|
43127
43145
|
this.handleUserLeave = this.handleUserLeave.bind(this);
|
43128
43146
|
this.handleEventError = this.handleEventError.bind(this);
|
43129
43147
|
this.handlePlayerEvent = this.handlePlayerEvent.bind(this);
|
43148
|
+
this.handleNetworkQuality = this.handleNetworkQuality.bind(this);
|
43130
43149
|
// Debug only
|
43131
43150
|
this.handleLocalAudioPropertiesReport = this.handleLocalAudioPropertiesReport.bind(this);
|
43132
43151
|
this.handleRemoteAudioPropertiesReport = this.handleRemoteAudioPropertiesReport.bind(this);
|
@@ -43142,6 +43161,7 @@ and limitations under the License.
|
|
43142
43161
|
*/ async connect() {
|
43143
43162
|
var _this__config_videoConfig;
|
43144
43163
|
const { botId, conversationId, voiceId } = this._config;
|
43164
|
+
this.dispatch(event_handler_EventNames.CONNECTING, {});
|
43145
43165
|
let roomInfo;
|
43146
43166
|
try {
|
43147
43167
|
// Step1 get token
|
@@ -43222,6 +43242,7 @@ and limitations under the License.
|
|
43222
43242
|
var _this__client;
|
43223
43243
|
await (null === (_this__client = this._client) || void 0 === _this__client ? void 0 : _this__client.disconnect());
|
43224
43244
|
this.isConnected = false;
|
43245
|
+
this._client = null;
|
43225
43246
|
this.dispatch(event_handler_EventNames.DISCONNECTED, {});
|
43226
43247
|
}
|
43227
43248
|
/**
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@coze/realtime-api",
|
3
|
-
"version": "1.0.5-alpha.
|
3
|
+
"version": "1.0.5-alpha.feed0d",
|
4
4
|
"description": "A powerful real-time communication SDK for voice interactions with Coze AI bots | 扣子官方实时通信 SDK,用于与 Coze AI bots 进行语音交互",
|
5
5
|
"keywords": [
|
6
6
|
"coze",
|
@@ -21,7 +21,6 @@
|
|
21
21
|
},
|
22
22
|
"license": "MIT",
|
23
23
|
"author": "jackshen <jackshen310@gmail.com>",
|
24
|
-
"sideEffects": false,
|
25
24
|
"type": "module",
|
26
25
|
"exports": {
|
27
26
|
".": {
|