当用户尝试从 Android 应用程序连接时,Agora 视频通话无法在 Web SDK 中工作

问题描述 投票:0回答:2
    eventHandler = object : IRtcEngineEventHandler() {
        override fun onJoinChannelSuccess(channel: String?, uid: Int, elapsed: Int) {
            Log.d("VideoCall1", "channel:$channel,uid:$uid,elapsed:$elapsed")
            openScreen(ScreenType.VIDEO_CALL_SCREEN)
        }

        override fun onUserJoined(uid: Int, elapsed: Int) {
            Log.d("VideoCall1", "onUserJoined:$uid")
            viewModel.onUserJoined(uid)
        }

        override fun onUserOffline(uid: Int, reason: Int) {
            Log.d("VideoCall1", "onUserOffline:$uid")
            viewModel.onUserOffline(uid)
        }
    }
    rtcEngine = RtcEngine.create(this, AppConstants.AGORA_APP_ID, eventHandler)

    rtcEngine.apply {
            enableVideo()
            setClientRole(0)
           // setChannelProfile(Constants.CHANNEL_PROFILE_COMMUNICATION)
            joinChannel(token, channelName, "", userId.toInt())
        }

移动用户可以看到网页用户,但网页用户无法看到移动用户。当网络用户加入频道时,我还会收到

onUserJoined
的回调。

我正在使用 io.agora.rtc:full-sdk:3.5.0 它适用于 https://webdemo.agora.io/agora-web-showcase/examples/Agora-Web-Tutorial-1to1-Web/

有人有建议或想法吗?

android agora.io agora-web-sdk-ng agora-implementation
2个回答
0
投票

好吧,我花了几个小时的尝试和错误才找到解决方案。我相信这是 AgoraRTC 中的一个错误,但我没有深入了解发生了什么。无论如何,我发现的黑客是这样的:

在Web端Agora RTM脚本中,登录时使用字符串uid:

this.client.login({ uid, token }); // uid had to be a string in my case

但是,在Agora文档中说uid的类型必须在网络和移动设备上匹配,因为您在移动设备上使用int,您可能也需要在网络上使用int,但是当我尝试使用int时,登录方法抛出了无效的uid类型错误!

但话又说回来,只有在加入频道时我向 AgoraRTC 客户端加入方法提供 null uid 时,它才有效:

// uid (last argument) must be null
client.join(options.appid, options.channel, options.token, null);

如果 join 函数中的 uid 与登录函数中的 uid 相同但解析为数字,它也可以工作,但如果两者都是字符串,则不行。如果两者都是数字也不起作用,登录方法会抛出无效的 uid 变量类型错误...

希望这可以帮助任何面临同样问题的人,因为这是一个非常奇怪的错误,在互联网上的其他地方找不到答案。


0
投票

我也有这个问题,但相反!

© www.soinside.com 2019 - 2024. All rights reserved.