RTC顺利接入

This commit is contained in:
fsy
2025-03-19 14:36:18 +08:00
parent 375d94ab26
commit 700985ca63
2 changed files with 23 additions and 10 deletions

View File

@@ -9,6 +9,9 @@ class AgoraService {
this.remoteUsers = {};
this.volumeIndicator = null;
this.vadEnabled = true;
this.appid = '01a1debc964a4c6a8df1de2a6ce7aa4d';
this.token = '007eJxTYHi+XWtqBkPmn71LGvdmPds7sfiQfomBxpt3XMfOC53fcjVegcHAMNEwJTUp2dLMJNEk2SzRIiUNyDdKNEtONU9MNEkpibmZ3hDIyPDYXo2JkQECQXwRhuT8vLLETCBZnJ+TGm9oYmluYMDAAACcPigI';
this.channel = 'convaiconsole_149700';
this.vadParams = {
interruptDurationMs: 160,
prefixPaddingMs: 300,
@@ -69,12 +72,13 @@ class AgoraService {
* @param {string} channel - The channel name to join
* @param {string} uid - The user ID (optional)
*/
async join(token, channel, uid = null) {
async join(agent_id, create_ts, status, uid = null) {
try {
this.uid = uid || `user_${Math.floor(Math.random() * 1000000)}`;
// Join the channel
await this.client.join(token, channel, this.uid);
this.uid = await this.client.join(this.appid, this.channel, this.token, uid);
console.log("successful! this.uid is ", this.uid);
this.isJoined = true;
// Create and publish local audio track
@@ -94,7 +98,9 @@ class AgoraService {
// Enable volume indicator
this.client.enableAudioVolumeIndicator();
console.log("status:", this.status);
return true;
} catch (error) {
console.error('Error joining channel:', error);