分享

tigase增加离线消息,message

 WindySky 2016-04-10
init.properties增加配置
--comp-name-1=message-archive
--comp-class-1=tigase.archive.MessageArchiveComponent

message-archive/archive-repo-uri=jdbc:mysql://192.168.1.15:3306/tigasedb?user=tigase&password=tigase&useUnicode=true&characterEncoding=UTF-8

--sm-plugins=+message-archive-xep-0136
sess-man/plugins-conf/message-archive-xep-0136/component-jid=message-archive@s3-1

sess-man/plugins-conf/message-archive-xep-0136/default-store-method=body
sess-man/plugins-conf/message-archive-xep-0136/required-store-method=body

历史记录全部保存,和记录类型指定为body,修改类MessageArchivePlugin

//~--- get methods ----------------------------------------------------------

    private boolean getAutoSave(final XMPPResourceConnection session)
                    throws NotAuthorizedException {
        /** comment by guahao
        if (requiredStoreMethod != StoreMethod.False)
            return true;

        Boolean auto = (Boolean) session.getCommonSessionData(ID + "/" + AUTO);

        if (auto == null) {
            try {
                String data = session.getData(SETTINGS, AUTO, "false");

                auto = Boolean.parseBoolean(data);
                session.putCommonSessionData(ID + "/" + AUTO, auto);
            } catch (TigaseDBException ex) {
                log.log(Level.WARNING, "Error getting Message Archive state: {0}", ex
                        .getMessage());
                auto = false;
            }
        }

        return auto;
        **/
        //modified for all save;
        return true;
    }

    private StoreMethod getStoreMethod(XMPPResourceConnection session)
                    throws NotAuthorizedException {
        /**comment by guahao
        StoreMethod save = (StoreMethod) session.getCommonSessionData(ID + "/" + DEFAULT_SAVE);

        if (save == null) {
            try {
                String data = session.getData(SETTINGS, DEFAULT_SAVE, defaultStoreMethod.toString());

                save = StoreMethod.valueof(data);
                session.putCommonSessionData(ID + "/" + DEFAULT_SAVE, save);
            } catch (TigaseDBException ex) {
                log.log(Level.WARNING, "Error getting Message Archive state: {0}", ex
                        .getMessage());
                save = StoreMethod.False;
            }
        }

        if (save.ordinal() < requiredStoreMethod.ordinal()) {
            save = requiredStoreMethod;
            session.putCommonSessionData(ID + "/" + DEFAULT_SAVE, save);
            try {
                setStoreMethod(session, save);
            } catch (TigaseDBException ex) {
                log.log(Level.WARNING, "Error updating message archiving level to required level {0}", ex.getMessage());
            }
        }
        return save;
        **/

        StoreMethod save = requiredStoreMethod;
        session.putCommonSessionData(ID + "/" + DEFAULT_SAVE, save);
        try {
            setStoreMethod(session, save);
        } catch (TigaseDBException ex) {
            log.log(Level.WARNING, "Error updating message archiving level to required level {0}", ex.getMessage());
        }
        return save;
    }


    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约

    类似文章 更多