![](/img/trans.png)
[英]Not able to join Chatroom smack/smackx, XMPP: Exception not-authorized (401)
[英]IN XMPP getting exception not-authorized(401), while submitting the form
我可以添加组,但它显示“房间从入口锁定,直到配置确认”。 我研究过但没有找到任何满意的答案。 以下是获取XMPP连接和提交表单的代码。 在发送表单时,它会抛出“未授权的例外”。
xmppConnection = connectionThread.getXMPPConnection();
if (xmppConnection == null) {
Application.getInstance().onError(R.string.NOT_CONNECTED);
return;
}
final MultiUserChat multiUserChat;
try {
multiUserChat = new MultiUserChat(xmppConnection, room);
// setConfig(multiUserChat);
} catch (IllegalStateException e) {
Application.getInstance().onError(R.string.NOT_CONNECTED);
return;
}
//提交表格的代码。
private void setConfig(MultiUserChat multiUserChat) {
try {
Form form = multiUserChat.getConfigurationForm();
Form submitForm = form.createAnswerForm();
for (Iterator<FormField> fields = submitForm.getFields(); fields
.hasNext();) {
FormField field = (FormField) fields.next();
if (!FormField.TYPE_HIDDEN.equals(field.getType())
&& field.getVariable() != null) {
submitForm.setDefaultAnswer(field.getVariable());
}
}
submitForm.setAnswer("muc#roomconfig_publicroom", true);
submitForm.setAnswer("muc#roomconfig_persistentroom", true);
multiUserChat.sendConfigurationForm(submitForm);
} catch (Exception e) {
e.printStackTrace();
}
}
为了回答这个问题,我只是调整你的评论。
你提前调用setConfig()
。 应在加入小组后调用。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.