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 ...
随机推荐
- alert(1) to win 16
- 触发redo写的几个条件
触发redo写的几个条件 作者:eygle |English [转载时请标明出处和作者信息]|[恩墨学院 OCM培训传DBA成功之道]链接:http://www.eygle.com/archive ...
- jmeter性能工具 使用手册(一)
前置条件: 在jmeter官网下载jmter 安装包 电脑有java 环境 使用步骤: 打开jmeter 2.新建线程 Test plan--->add-->theads(users)-- ...
- zabbix邮件报警通过脚本来发送邮件
zabbix默认邮件报警会将各个报警接收人单独发送邮件,为了使邮件能以群发的方式统一一封邮件发送所有接收人,需要改成脚本的形式: sendemail.py: #!/usr/bin/python imp ...
- hdu 5511 Minimum Cut-Cut——分类讨论思想+线段树合并
题目:http://acm.hdu.edu.cn/showproblem.php?pid=5511 题意:割一些边使得无向图变成不连通的,并且恰好割了两条给定生成树上的边.满足非树边两段一定在给定生成 ...
- Linux shell 归纳之 cp
1. 复制文件夹folder1(包括所有子文件夹和文件), 并命名为folder2 # cp -r /usr/folder1 folder2 2. 复制文件file1 到它的上一级的目录的abc文件夹 ...
- (转)GIS理论知识(三)之ArcGIS平台、SuperMap超图平台和开源平台
3.1.ArcGIS平台 ArcGIS为美国ESRI公司研发的产品,为用户提供一个可伸缩的,全面的GIS平台.ArcObjects包含了许多的可编程组件,从细粒度的对象(例如单个的几何对象)到粗粒度的 ...
- 洛谷P1378 油滴扩展(搜索)
洛谷P1378 油滴扩展 直接暴力搜索更新答案就可以了. 时间复杂度为 \(O(n!)\) . #include<stdio.h> #include<stdlib.h> #in ...
- ruby+selenium-webdriver测试
参考这里的博客https://www.cnblogs.com/smiling007/p/5116662.html
- 导入maven项目pom.xml首行报错missing artifact。。。
解决方法: 在maven地址(如一般默认的地址C:\Users\Administrator\.m2\repository\)找到对应包名 加后缀名为.lastUpdated文件(如:ojdbc14.l ...