openfire muc 移除成员
来源:互联网 发布:中公教育网络课程 编辑:程序博客网 时间:2024/06/10 00:39
muc添加成员到数据库可参考 将Openfire中的MUC改造成类似QQ群一样的永久群
插件
插件是一位大神参考第一篇文章改进后编写的插件,进测试可以直接使用。
----------------------------------------分割线------------------------------------------------------------
本文主要介绍如何移除成员
基本思路:
1、openfire控制台的muc-room-occupants.jsp页面有踢出成员功能
jsp源码
// Kick nick specified if (kick != null) { MUCRole role = room.getOccupant(nickName); if (role != null) { try { room.kickOccupant(role.getUserAddress(), XMPPServer.getInstance().createJID(webManager.getUser().getUsername(), null), null, ""); // Log the event webManager.logEvent("kicked MUC occupant "+nickName+" from "+roomName, null); // Done, so redirect response.sendRedirect("muc-room-occupants.jsp?roomJID="+URLEncoder.encode(room.getJID().toBareJID(), "UTF-8")+"&nickName="+URLEncoder.encode(role.getNickname(), "UTF-8")+"&deletesuccess=true"); return; } catch (NotAllowedException e) { // Done, so redirect response.sendRedirect("muc-room-occupants.jsp?roomJID="+URLEncoder.encode(room.getJID().toBareJID(), "UTF-8")+"&nickName="+URLEncoder.encode(role.getNickname(), "UTF-8")+"&deletefailed=true"); return; } } }
2、可以看到核心的kickOccupant方法,我们来看实现类LocalMUCRoom中的具体实现方法
public Presence kickOccupant(JID jid, JID actorJID, String actorNickname, String reason) throws NotAllowedException { System.out.println("jid="+jid.toString()+" ==== actorJID="+actorJID); // Update the presence with the new role and inform all occupants Presence updatedPresence = changeOccupantRole(jid, MUCRole.Role.none);//改变成员在房间的角色 if (updatedPresence != null) { Element frag = updatedPresence.getChildElement( "x", "http://jabber.org/protocol/muc#user"); // Add the status code 307 that indicates that the user was kicked frag.addElement("status").addAttribute("code", "307"); // Add the reason why the user was kicked if (reason != null && reason.trim().length() > 0) { frag.element("item").addElement("reason").setText(reason); } // Effectively kick the occupant from the room kickPresence(updatedPresence, actorJID, actorNickname);//移除成员 //Inform the other occupants that user has been kicked broadcastPresence(updatedPresence, false);//广播 } return updatedPresence; }
主要在上述方法添加删除数据库方法就可以了。
但是发现如果房间设置只允许成员加入,但是明明移除了成员,数据库也删除了,但是在服务器未重启的情况下用户还是可以进入房间。
研究进入房间的源码LocalMucRoom的joinRoom方法,发现有判断 members.includesKey(bareJID)。
所以我们可以在删除数据库后把成员remove。
3、还需要判断一点,用户是否在房间内,如果不在只需删除数据库。
------------------------以下是部分源码截图------------------------------------------------------------------
1、插件
2、方法
3、kickMember方法
操作数据库的代码就不在贴出了。
ps:第一次写博客,写的不好,请多多指教
0 0
- openfire muc 移除成员
- mac系统移除openfire
- OpenFire源码学习之八:MUC用户聊天室
- openfire的MUC改造类似QQ永久群
- openfire的MUC改造类似QQ永久群(二)
- 将Openfire中的MUC改造成类似QQ群一样的永久群
- 将Openfire中的MUC改造成类似QQ群一样的永久群
- 将Openfire中的MUC改造成类似QQ群一样的永久群
- Strophe.js连接XMPP服务器Openfire、Tigase实现Web私聊、群聊(MUC)
- 将Openfire中的MUC改造成类似QQ群一样的永久群
- Strophe.js连接XMPP服务器Openfire、Tigase实现Web私聊、群聊(MUC)
- Strophe.js连接XMPP服务器Openfire、Tigase实现Web私聊、群聊(MUC)
- 在leangoo项目里怎么批量导入成员,更改项目成员权限,移除项目成员?
- openfire删除永久群成员操作
- [置顶] openfire删除永久群成员操作
- Wildfire之MUC功能分析
- Ejabberd MUC的配置
- muc.lists.freebsd.current
- Algorithm——Quicksort(快速排序)
- 密钥分散算法简析
- C语言 动态申请数组内存
- Entity Framework 的事务 DbTransaction
- NFS服务器搭建 unbuntu
- openfire muc 移除成员
- 转载的socks4 socks5 rfc1928一大堆
- EntityClient 介绍
- 反转法_Face The Right Way(POJ.3276)
- layui里的上传控件问题
- ObjectQuery查询及方法
- 界面侧滑
- Python做图像识别和应用
- 实现performSelector 传递多个参数