我可以使用来自 agora.io 的临时令牌进行基本视频通话,但是当我从我的服务器创建令牌时,出现此错误。我正在使用 NgxAgora 数据包。我尝试设置区号,但在 NgxAgora 中没有此选项。这是我的角度代码:
this.api.getmethod("appointment/gettoken/" + atob(this.acRouter.snapshot.params.id)).subscribe((data) => {
this.token = data['token']
this.client = this.ngxAgoraService.createClient({ mode: 'rtc', codec: 'h264' });
this.assignClientHandlers();
this.localStream = this.ngxAgoraService.createStream({ streamID: this.uid, audio: true, video: true, screen: false });
this.assignLocalStreamHandlers();
// Join and publish methods added in this step
this.initLocalStream(() => this.join(uid => this.publish(), error => console.error(error)));
})
我使用 C# 在 web api 端使用这个函数:
public string createagoratoken(string appointmentUid,DateTime appointmentDate,int appointmentId)
{
var tokenbuilder = new AgoraEntegration.Media.AccessToken(AgoraEntegration.AgoraEnums.AppEnums.appId, AgoraEntegration.AgoraEnums.AppEnums.appCertificate, appointmentUid, appointmentId.ToString());
appointmentDate = appointmentDate.AddMinutes(20);
Int32 unixTimestamp = (Int32)(appointmentDate.Subtract(new DateTime(1970, 1, 1))).TotalSeconds;
tokenbuilder.addPrivilege(AgoraEntegration.Media.Privileges.kJoinChannel, (uint)unixTimestamp);
tokenbuilder.addPrivilege(AgoraEntegration.Media.Privileges.kInvitePublishAudioStream, (uint)unixTimestamp);
tokenbuilder.addPrivilege(AgoraEntegration.Media.Privileges.kInvitePublishVideoStream,(uint)unixTimestamp);
string token = tokenbuilder.build();
return token;
}
我还使用这个库作为 C# 的访问令牌 Github 访问令牌
隔江千里
相关分类