【发布时间】:2016-10-18 22:27:37
【问题描述】:
我已经使用 Smack Api(4.1.4) 成功为 XMPP 创建了登录连接。现在我正在尝试使用创建 MultiUserChat,
try {
String myMUCName = "TestGroup";
String myMUCService = "conference.(my local ip)";
String myMUCfullName = myMUCName + "@" + myMUCService;
String userName = "Test5";
MultiUserChatManager manager = MultiUserChatManager.getInstanceFor(connection);
MultiUserChat muc = manager.getMultiUserChat(myMUCfullName);
muc.create(userName);
Log.d(LOCAL_TAG, "createGroupChat -- Group CEATED Successfully ");
Form form = muc.getConfigurationForm();
Form submitForm = form.createAnswerForm();
List<FormField> fields = form.getFields();
Log.d(LOCAL_TAG, "createGroupChat -- fields.size(): "+fields.size());
for (int i = 0; i < fields.size(); i++) {
FormField field = (FormField) fields.get(i);
if (!FormField.Type.hidden.equals(field.getType()) && field.getVariable() != null) {
submitForm.setDefaultAnswer(field.getVariable());
}
}
List owners = new ArrayList();
owners.add(userName); //Own user
owners.add("Test7"); //Another user
submitForm.setAnswer("muc#roomconfig_roomowners", owners);
submitForm.setAnswer("muc#roomconfig_publicroom", true);
submitForm.setAnswer("muc#roomconfig_persistentroom", true);
muc.sendConfigurationForm(new Form(DataForm.Type.submit));
//muc.sendConfigurationForm(submitForm);
Log.d(LOCAL_TAG, "createGroupChat -- Sent Configuration");
muc.join(TestGroup);
Log.d(LOCAL_TAG, "createGroupChat -- Group Joined Successfully -- owners.size(): "+owners.size());
但是在创建组时我遇到了一个例外
"org.jivesoftware.smack.XMPPException$XMPPErrorException: XMPPError: forbidden - auth".
希望如此,这个异常发生在代码中
muc.sendConfigurationForm(submitForm);
出于这个原因,对此进行了评论。因为在那段代码之后我没有得到日志。为了解决这个问题,我已将该代码更改为
muc.sendConfigurationForm(new Form(DataForm.Type.submit));
它修复了该异常并为我创建了一个组,因为我可以看到打印的日志并且可以看到我的组在开火中。但是我确实知道如何通过这样做添加我为该组选择的用户,因为所有者列表(或提交表单)在任何地方都不包含在其中。我不知道发生了什么,我不确定我做对了。请建议我如何进行。提前致谢。
【问题讨论】:
-
嗨@Sangeetha 我也遇到了同样的问题,你能描述一下你是如何解决这个错误的吗?