我正在尝试使用Smack创建一个即时聊天室,但服务器返回给我一个包含错误代码401和type="AUTH“的IQ包,以及一个消息包,其中包含一条消息,即在确认配置之前,房间已锁定
final MultiUserChat muc = new MultiUserChat(connection, chatName+"@conference.123");
try {
muc.sendConfigurationForm(new Form(Form.TYPE_SUBMIT));
muc.create(chatName);
} catch (XMPPException e) {
Log.e("Exception", e.getMessage());
}这会产生一个异常(未授权(401))。以下是从服务器收到的两个数据包:
<iq id="J1O5y-5" to="akshay@123/Smack" from="test@conference.123" type="error"><error code="401" type="AUTH"><not-authorized xmlns="urn:ietf:params:xml:ns:xmpp-stanzas"/></error></iq>和
<message to="akshay@123/Smack" from="test@conference.123" type="groupchat"><body>This room is locked from entry until configuration is confirmed.</body></message>那么,我需要对服务器配置进行任何更改吗?或者代码中是否存在任何问题?
发布于 2013-10-26 15:10:58
如下所示更改顺序如何:
muc.create(nickName);
muc.sendConfigurationForm(new Form(Form.TYPE_SUBMIT));希望这能有所帮助:)
发布于 2014-10-28 18:37:25
这对我很管用。请试一下这个。
public void createRoom(String r,String n) throws XMPPException {
// TODO Auto-generated method stub
String t = r + "@conference.localhost";
MultiUserChat muc = new MultiUserChat(connection, t);
muc.create(n);
muc.sendConfigurationForm(new Form(Form.TYPE_SUBMIT));
}https://stackoverflow.com/questions/19488224
复制相似问题