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中的sshd服务

    Linux中的sshd服务,主要用于pst终端,远程连接到linux服务中 看sshd服务状态 service sshd status 停止sshd服务 service sshd stop 启动ssh ...

  2. 【串线篇】spring boot自动配置精髓

    一.SpringBoot启动会加载大量的自动配置类即绿色部分 二.我们看我们需要的功能有没有SpringBoot默认写好的自动配置类: 比如HttpEncodingAutoConfiguration ...

  3. overflow hidden 遇上absolute失效

    原文地址 背景 这几天开发的时候遇到了个问题,如图1. 写了个demo 由于页面并没有进行整体缩放,导致在小屏幕手机上显示会有异常.PM要求能够显示最后一个完整的标签. 当在iPhone5手机上查看页 ...

  4. navicat的使用(测试库和正式库同步)以及用plsql改表字段属性

    说明:数据库的操作,除了查询,最好先做好备份,比如数据同步.更新.修改或删除之类的: netstat -antp   查看mysql端口 firewall -cmd --list-all    查看防 ...

  5. C#中命名空间,C#程序中的一种代码组织形式,主要用来标识类的可以范围,引用using 命名空间

    C# C#中命名空间,C#程序中的一种代码组织形式,主要用来标识类的可以范围 use system; use system.collect.core; namespace sss{ } using 命 ...

  6. oppo面试题

    1.synchronized和Lock有什么区别?哪个可重入?哪个效率高? synchronized和Lock都用于线程同步的场景中. synchronized是jdk的关键字,用来构造同步代码块或者 ...

  7. 匈牙利算法&模板O(mn)HDU2063

    #include<cstdio> #include<cstring> #define maxn 510 using namespace std; int k,g,b,x,y,a ...

  8. jdbc odbc JDBC-ODBC

    https://zh.wikipedia.org/zh-cn/ODBC ODBC(Open Database Connectivity,开放数据库互连)提供了一种标准的API(应用程序编程接口)方法来 ...

  9. Android7.1后对于Toast类型窗口的限制

    在处理问题的时候,经常会遇到ANR,停止运行等问题,经过分析和验证,和如下的一行关键log有关 WindowManager: Adding more than one toast window for ...

  10. Vagrant 入门 - box

    原文地址 Vagrant 使用基础镜像来快速克隆虚拟机,而不是从头开始构建虚拟机.这些基础镜像在 Vagrant 中被称为"box",并且指定用于 Vagrant 环境的 box ...