Reputation: 31
created() {
let $ = this;
// init AgoraRTC local client
const config = {
mode: "rtc",
codec:"h264",
areaCode: [AgoraRTC.AREAS.GLOBAL]
};
$.client = AgoraRTC.createClient(config);
$.client.init($.appId, () => {
console.log("AgoraRTC client initialized");
$.subscribeStreamEvents();
$.client.join($.appId, $.channel, $.uid, function(uid) {
console.log("User " + uid + " join channel successfully");
console.log("At " + new Date().toLocaleTimeString());
// create local stream
// It is not recommended to setState in function addStream
$.localStream = this.streamInit(uid, $.attendeeMode, $.videoProfile);
$.localStream.init(
() => {
if ($.attendeeMode !== "audience") {
$.addStream($.localStream, true);
$.client.publish($.localStream, err => {
console.log("Publish local stream error: " + err);
});
}
$.readyState = true;
},
err => {
console.log("getUserMedia failed", err);
$.readyState = true;
}
);
},function(err) {
console.error("client join failed", err);
});//end join
});//end init
},
Agora installed using npm
npm i agora-rtc-sdk
"agora-rtc-sdk": "^3.1.2", "vue": "^2.5.17", "vuetify": "^2.2.9"
in the above code
$.client.join($.appId, $.channel, $.uid, function(uid) {
this line keep joining but did not succeed and also do not gives failure error. it just keep trying to connect to server.
here is the screenshot of errors/warnings
Please help me I'm stuck on it for 2 days And Sorry for bad english
Upvotes: 0
Views: 1672
Reputation: 11
I think the documentation is a bit tricky on this one. The client.join()
function accepts 4 arguments as follows:
client.join(APPID, CHANNEL, TOKEN(can be null), UID(optional), function(uid){
// uid returned
})
So update your code to read:
$.client.join($.appId, $.channel, null, function(uid) {
I'm actually using the AgoraWebSDK NG for my VueJS project. You can checkout the guide to migration here: https://agoraio-community.github.io/AgoraWebSDK-NG/docs/en/migration_guide.
Upvotes: 1