zoukankan      html  css  js  c++  java
  • 判断openfire用户的状态

    /**
    * 判断openfire用户的状态
    * 说明 :必须要 openfire加载 presence 插件,同时设置任何人都可以访问
    * /status?jid=user1@my.openfire.com&type=xml 返回值 : 0 - 用户不存在; 1 - 用户在线; 2 -用户离线
    * 示例:http://192.168.1.254:9090/plugins/presence/status?jid=13817764475@192.168.1.254&type=xml

    * @后面的参数是服务器名称,我测试时服务器名称写为了192.168.1.254

    */
    public static short IsUserOnLine(String strUrl) {
    strUrl = "http://192.168.1.254:9090/plugins/presence/status?jid=13817764475@192.168.1.254&type=xml";
    short shOnLineState = 0; // -不存在-
    try {
    URL oUrl = new URL(strUrl);
    URLConnection oConn = oUrl.openConnection();
    if (oConn != null) {
    BufferedReader oIn = new BufferedReader(new InputStreamReader(oConn.getInputStream()));
    if (null != oIn) {
    String strFlag = oIn.readLine();
    oIn.close();

    if (strFlag.indexOf("type="unavailable"") >= 0) {
    shOnLineState = 2;
    }
    if (strFlag.indexOf("type="error"") >= 0) {
    shOnLineState = 0;
    } else if (strFlag.indexOf("priority") >= 0 || strFlag.indexOf("id="") >= 0) {
    shOnLineState = 1;
    }
    }
    }
    } catch (Exception e) {

    }
    return shOnLineState;
    }

    // 离线時,向offline表写数据
    OfflineMessageStore offlineMessageStore = new OfflineMessageStore();
    offlineMessageStore.addMessage(message);

  • 相关阅读:
    JavaScript伪协议
    http-equiv
    js 获取鼠标坐标
    js daily
    Swift中属性Properties
    Swift中类和结构体
    Swift和Java在枚举方面的比较
    Swift特有语法:闭包
    Swift和Java在函数(method/方法)方面的比较
    Swift和Java控制流比较
  • 原文地址:https://www.cnblogs.com/shihaiming/p/5923022.html
Copyright © 2011-2022 走看看