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 ...
随机推荐
- 2018-10-01-weekly
Algorithm 77. 组合 What 给定两个整数 n 和 k,返回 1 ... n 中所有可能的 k 个数的组合. How 利用递归的思想,当凑够k个数时,就回退回去,remove掉一个数,在 ...
- bzoj1875 [SDOI2009]HH去散步 矩阵快速幂
题目传送门 https://lydsy.com/JudgeOnline/problem.php?id=1875 题解 如果没有这个"不能立刻沿着刚刚走来的路走回",那么这个题就是一 ...
- js如何判断用户使用的设备类型及平台
前端开发经常遇到需要判断用户的浏览设备,是pc端还是移动端,移动端使用的是什么手机系统?android.ios.ipad.windows phone等等,有时候还需要知道用户浏览页面是在微信中打开还是 ...
- What are the differences between an LES-SGS model and a RANS based turbulence model?
The biggest difference between LES and RANS is that, contrary to LES, RANS assumes that \(\overline{ ...
- wrapper配置文件详解
参考资料 http://www.tuicool.com/articles/jqMv2q 文件编码,每个配置文件起始位置必须指定该文件的编码格式 encoding=UTF-8 如果包含配置文件出现问题可 ...
- Task5.NB_SVM_LDA
参考:https://blog.csdn.net/u013710265/article/details/72780520 贝叶斯公式就一行: P(Y|X)=P(X|Y)P(Y)P(X) 而它其实是由以 ...
- python——解释型语言
编程语言分三大类 : 低级语言 . 汇编语言 . 高级语言. 现代计算机都是基于 图灵机模型 制造的. 因此计算机的内部只能接受二进制数据.而用二进制代码 0 1 描述的指令叫 ...
- 英语单词omitting
omitting 来源——报错 [root@centos7 ~]# cp /etc/ /bin cp: omitting directory ‘/etc/’ [root@centos7 ~]# cp ...
- NodeJS使用puppeteer进行截图
const puppeteer = require('/home/ordinaryUser_2/automation/NodeJS/node/lib/node_global/lib/node_modu ...
- 【HDOJ6681】Rikka with Cake(扫描线,线段树)
题意:给定一个n*m的平面,有k条垂直或平行的直线,问将平面分成了几个互不联通的部分 n,m<=1e9,k<=1e5 思路: 刻在DNA里的二维数点 #include<bits/st ...