该错误通常表示SDK无法连接音频服务器。 可以通过将SDK引擎设置为默认设置来解决此错误。 可以使用以下代码:
private IRtcEngine mRtcEngine;
void Start()
{
mRtcEngine = IRtcEngine.GetEngine("YOUR_APP_ID_HERE");
// Set channel profile to Communication
mRtcEngine.SetChannelProfile(CHANNEL_PROFILE.CHANNEL_PROFILE_COMMUNICATION);
// Set client role as broadcaster
mRtcEngine.SetClientRole(CLIENT_ROLE_TYPE.CLIENT_ROLE_BROADCASTER);
// Join the channel
string token = null; // Set your token here if using an App Certificate
string channelName = "YOUR_CHANNEL_NAME_HERE";
uint uid = 0; // Set your User ID here if necessary
int result = mRtcEngine.JoinChannel(token, channelName, null, uid);
if (result != 0)
{
Debug.LogErrorFormat("Join channel failed {0}", result);
}
}
此代码将默认将引擎设置为Communication频道配置,并将客户端的角色设置为观众(即使用mRtcEngine.SetClientRole(CLIENT_ROLE_TYPE.CLIENT_ROLE_BROADCASTER);注释)。 然后使用mRtcEngine.JoinChannel()方法加入指定的频道。