XMPP即时通讯协议使用(十三)——获取当前在线用户或关闭指定用户
1、开启REST API插件或根据需求修改其插件源码;
2、添加服务器->服务器管理->系统属性中添加
plugin.restapi.enabled=true
3、pom依赖
<dependency>
<groupId>org.igniterealtime</groupId>
<artifactId>rest-api-client</artifactId>
<version>1.1.4</version>
</dependency>
4、相关代码
import java.util.List;
import org.igniterealtime.restclient.RestApiClient;
import org.igniterealtime.restclient.entity.AuthenticationToken;
import org.igniterealtime.restclient.entity.SessionEntity;
public class Test {
public static void main(String[] args) {
// Set Shared secret key
AuthenticationToken authenticationToken = new AuthenticationToken("admin", "123456");
// Set Openfire settings (9090 is the port of Openfire Admin Console)
RestApiClient restApiClient = new RestApiClient("http://127.0.0.1", 9090, authenticationToken);
// Request all active Sessions
System.out.println(restApiClient.getSessions());
// Request all active Sessions from a specific user
System.out.println(restApiClient.getSessions("admin"));
List<SessionEntity> list = restApiClient.getSessions("admin").getSessions();
for(SessionEntity session:list) {
System.out.println(session.getSessionId());
}
// 关闭指定用户
restApiClient.deleteSessions("admin");
}
}
5、补充
Openfire源码下载地址:https://www.igniterealtime.org/downloads/source.jsp
rest-api-client源码地址:https://github.com/igniterealtime/REST-API-Client
XMPP即时通讯协议使用(十三)——获取当前在线用户或关闭指定用户的更多相关文章
- XMPP即时通讯协议使用(前传)——协议详解
XMPP详解 XMPP(eXtensible Messaging and Presence Protocol,可扩展消息处理和现场协议)是一种在两个地点间传递小型结构化数据的协议.在此基础上,XMPP ...
- XMPP即时通讯协议使用(六)——开发Openfire聊天记录插件
转载地址:http://www.cnblogs.com/hoojo/archive/2013/03/29/openfire_plugin_chatlogs_plugin_.html 开发环境: Sys ...
- XMPP即时通讯协议使用(十)——好友关系状态
sub ask recv 订阅 询问 接受 含义 substatus -1- 应该删除这个好友 Indicates that the roster item should be ...
- XMPP即时通讯协议使用(二)——基于Smack相关操作
package com.test; import java.util.ArrayList; import java.util.Collection; import java.util.Iterator ...
- XMPP即时通讯协议使用(七)——利用Strophe实现WebIM及strophe.plugins插件使用
Strophe简介与Openfire配置 Strophe.js是为XMPP写的一个js类库.因为http协议本身不能实现持久连接,所以strophe利用BOSH模拟实现持久连接. 官方文档: http ...
- xmpp即时通讯协议的特性---长处和缺点!
xmpp协议的定义? XMPP是一种基于标准通用标记语言的子集XML的协议,它继承了在XML环境中灵活的发展性. 因此.基于XMPP的应用具有超强的可扩展性.经过扩展以后的XMPP能够通过发送扩展的信 ...
- XMPP即时通讯协议使用(三)——订阅发布、断开重连与Ping
package com.testV3; import java.util.List; import org.jivesoftware.smack.ConnectionListener; import ...
- XMPP即时通讯协议使用(十二)——基于xmpp搭建简单的局域网WebRTC
创建HTML和JS ofwebrtc.html <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml" ...
- XMPP即时通讯协议使用(四)——Openfire服务器源码编译与添加消息记录保存
下载Openfire源码 下载地址:https://www.igniterealtime.org/downloads/index.jsp,当前最新版本为:4.2.3 Eclipse上部署Openfir ...
随机推荐
- [python 学习] logging模块
1.将简单日志打印到屏幕: import logging logging.debug('debug message') logging.info('info message') logging.war ...
- maven 配置发布仓库
·首先,在工程的pom.xml中添加仓库信息 <distributionManagement> <repository> <id>releases</id&g ...
- 快速开发框架下载地址(github)
eladmin:https://github.com/elunez/eladmin bootDo:https://www.oschina.net/p/bootdo
- django 修改字段后,同步数据库,失败:django.db.utils.InternalError: (1054, "Unknown column 'api_config.project_id_id' in 'field list'")
问题原因是,修改字段后,同步失败了,然后执行查询的时候,就会提示这个错误,这个字段没有 最暴力的方法可以直接在数据库中修改字段,但是修改后,models没同步,可能会存在问题,因此开始我的百度之旅(这 ...
- LeetCode--040--组合总和 II(java)
给定一个数组 candidates 和一个目标数 target ,找出 candidates 中所有可以使数字和为 target 的组合. candidates 中的每个数字在每个组合中只能使用一次. ...
- 迁移数据时 timestamp类型字段报错: 1067 - Invalid default value for 'login_time'
MySQL数据库升级 8.0.13,原版本5.5:执行导出来的SQL文件时报错 1067 - Invalid default value for 'login_time' 原因:MySQL 5.6以后 ...
- Linux学习-DNS服务相关
一.DNS服务简介 1.基本概念 (1) DNS( Domain Name System )域名系统,是一种组织成域层次结构的计算机和网络服务命名系统,是一个应用层协议,使用TCP与UDP的53端口, ...
- fiddler常见问题
捕获https: tools>options https>decrypt https traffic :安装证书捕获客户端请求: tools>options connections& ...
- 科讯使用的:ckeditor编辑器.复制word图片.一直沾不上去.谁有好的解决办法呢
在之前在工作中遇到在富文本编辑器中粘贴图片不能展示的问题,于是各种网上扒拉,终于找到解决方案,在这里感谢一下知乎中众大神以及TheViper. 通过知乎提供的思路找到粘贴的原理,通过TheViper找 ...
- HDU 3605 Escape(二分图多重匹配问题)
Escape Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total Subm ...