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即时通讯协议使用(十三)——获取当前在线用户或关闭指定用户的更多相关文章

  1. XMPP即时通讯协议使用(前传)——协议详解

    XMPP详解 XMPP(eXtensible Messaging and Presence Protocol,可扩展消息处理和现场协议)是一种在两个地点间传递小型结构化数据的协议.在此基础上,XMPP ...

  2. XMPP即时通讯协议使用(六)——开发Openfire聊天记录插件

    转载地址:http://www.cnblogs.com/hoojo/archive/2013/03/29/openfire_plugin_chatlogs_plugin_.html 开发环境: Sys ...

  3. XMPP即时通讯协议使用(十)——好友关系状态

    sub  ask  recv 订阅 询问 接受 含义 substatus -1-  应该删除这个好友          Indicates that the roster item should be ...

  4. XMPP即时通讯协议使用(二)——基于Smack相关操作

    package com.test; import java.util.ArrayList; import java.util.Collection; import java.util.Iterator ...

  5. XMPP即时通讯协议使用(七)——利用Strophe实现WebIM及strophe.plugins插件使用

    Strophe简介与Openfire配置 Strophe.js是为XMPP写的一个js类库.因为http协议本身不能实现持久连接,所以strophe利用BOSH模拟实现持久连接. 官方文档: http ...

  6. xmpp即时通讯协议的特性---长处和缺点!

    xmpp协议的定义? XMPP是一种基于标准通用标记语言的子集XML的协议,它继承了在XML环境中灵活的发展性. 因此.基于XMPP的应用具有超强的可扩展性.经过扩展以后的XMPP能够通过发送扩展的信 ...

  7. XMPP即时通讯协议使用(三)——订阅发布、断开重连与Ping

    package com.testV3; import java.util.List; import org.jivesoftware.smack.ConnectionListener; import ...

  8. XMPP即时通讯协议使用(十二)——基于xmpp搭建简单的局域网WebRTC

    创建HTML和JS ofwebrtc.html <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml" ...

  9. XMPP即时通讯协议使用(四)——Openfire服务器源码编译与添加消息记录保存

    下载Openfire源码 下载地址:https://www.igniterealtime.org/downloads/index.jsp,当前最新版本为:4.2.3 Eclipse上部署Openfir ...

随机推荐

  1. Linux内核设计与实现 总结笔记(第五章)系统调用

    系统调用 内核提供了用户进程和内核交互的接口,使得应用程序可以受限制的访问硬件设备. 提供这些接口主要是为了保证系统稳定可靠,避免应用程序恣意妄行. 一.内核通信 系统调用在用户空间进程和硬件设备之间 ...

  2. 求能粘贴Word 内容(含图片)的在线编辑器

    word图片转存,是指UEditor为了解决用户从word中复制了一篇图文混排的文章粘贴到编辑器之后,word文章中的图片数据无法显示在编辑器中,也无法提交到服务器上的问题而开发的一个操作简便的图片转 ...

  3. C/C++ | 并查集:用于检查一个图上有没有环

     没有环的过程分析: #include<stdio.h> #include<stdlib.h> #include<iostream> #define VERTICE ...

  4. 5 October

    POJ2676 Sudoku 位运算 + 搜索.更好的优化方法:方案数最小的空格先填. 把某一位 置为 0:a &=~ (1<<n) 把某一位 置为 1:a |= (1<&l ...

  5. 笨办法学Python(learn python the hard way)--练习程序31-35

    下面是练习31-练习35,基于python3 #ex31.py 1 print("You enter a dark room witn two doors. Do you go throug ...

  6. js数组声明+split()方法

    split()方法:var words = sentence.split(' '): "hello".split("", 3) //可返回 ["h&q ...

  7. oracle系统对象

    select * from all_tab_comments-- 查询所有用户的表,视图等 select * from user_tab_comments  -- 查询本用户的表,视图等 select ...

  8. 表单修饰符 number、trim、lazy

    number修饰符 <input type="number" v-model.number="age"> 结论:age 类型则为number,非字符 ...

  9. Git学习及使用

    一.认知git理论 1.git出现的背景 版本控制 版本控制是一种记录一个或若干文件内容变化,以便将来查阅特定版本修订情况的系统. 许多人习惯用复制整个项目目录的方式来保存不同的版本,或许还会改名加上 ...

  10. delphi 神经网络 学习

    https://github.com/uldercarrilho/ParallelNeuralNetwork