【发布时间】:2014-08-19 13:25:35
【问题描述】:
我正在使用下面在 xmpp 中获得邀请进行群聊,并且也成功获得了邀请,但在接受邀请的地方无法接受邀请。
这是我邀请和接受群聊的代码:
public static void addMUC() {
MultiUserChat.addInvitationListener(connection, new InvitationListener() {
@Override
public void invitationReceived(Connection conn, final String room, String invitor,
String reason, String password, Message message) {
Constant.showGroupChatInvitationAlert(Constant.MESSAGE_GROUP_CHAT, reason,
room,conn,invitor, _sPrefs.getString("USERNAME", ""), _sPrefs.getString("PASSWORD", ""));
}
});
}
public static void showGroupChatInvitationAlert(final String title, final String message,
final String roomname,final Connection conn,final String inviter, final String user,final String password) {
new Thread(new Runnable() {
public void run() {
joinMultiUserChat(Constant.userName, Constant.password, roomname.split("@")[0]);
}
}).start();
}
public static MultiUserChat joinMultiUserChat(String user, String password, String roomsName) {
try {
XMPPSmackConnection.getInstance();
StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
StrictMode.setThreadPolicy(policy);
// Create a MultiUserChat window using XMPPConnection
MultiUserChat muc = new MultiUserChat(XMPPSmackConnection.connection, roomsName
+ "@conference." + XMPPSmackConnection.connection.getServiceName());
// The number of chat room services will decide to accept the historical record
DiscussionHistory history = new DiscussionHistory();
history.setMaxStanzas(0);
//history.setSince(new Date());
// Users to join in the chat room
muc.join(user, password, history, SmackConfiguration.getPacketReplyTimeout());
System.out.println("The conference room success....");
return muc;
} catch (XMPPException e) {
e.printStackTrace();
System.out.println("The conference room to fail....");
return null;
}
}
【问题讨论】:
-
xmpp 支持群聊,但它不是持久性,您必须在本地存储所有邀请和数据,因为如果连接中断,它会清除所有组相关数据
-
对不起.. 没明白你想说什么..
-
有没有办法自动接受邀请?
标签: android xmpp chat invitation