您的位置:首页 > 其它

tigase增加离线消息和保存历史记录

2014-11-12 16:51 357 查看
http://www.verydemo.com/article_c81_i83197.html


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_S***E);
		
		if (save == null) {
			try {
				String data = session.getData(SETTINGS, DEFAULT_S***E, defaultStoreMethod.toString());

				save = StoreMethod.valueof(data);
				session.putCommonSessionData(ID + "/" + DEFAULT_S***E, 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_S***E, 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_S***E, 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;
	}


知道这个后,你会知道,并非安装了message-archive 组件后,日志就可以记录了;而是要客户端允许了;

那么如何安装?

把message-archive.jar 拷贝到 jars/tigase-message-archiving.jar 然后再 etc/init.properties 写下如下配置;

####begin

--comp-name-1=m

参考如下文章一切ok
http://hi.baidu.com/bngoogle/archive/tag/tigase https://projects.tigase.org/projects/message-archiving/wiki/Configuration https://projects.tigase.org/projects/message-archiving/wiki/Configuration


Configuration


Basic configuration

Below is example configuration required by component:

--comp-name-3=message-archive
--comp-class-3=tigase.archive.MessageArchiveComponent

message-archive/archive-repo-uri=jdbc:mysql://localhost/messagearchivedb?user=test&password=test

--sm-plugins=message-archive-xep-0136
sess-man/plugins-conf/message-archive-xep-0136/component-jid=message-archive@local-machine-name


In this example configuration is passed connection string to database (if connection string is empty default user repository will be used as database to store archived messages) and JID of message
archive component.
If
component-jid
option is omitted message-archive@local-machine-name will be used as
component-jid
.


Additional options

We added following additional features, which are available since 1.0.1 release.


Setting default value of archiving level for messages on a server

Settting this property will change default archiving level for messages for every account on server for which per account default archiving level is not set. User will be able to change this value
setting default modes as described in XEP-0136 section 2.4
Example in which we set default server message archiving level to
message
:

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



Setting required value of archiving level for messages on a server

Settting this property will change required archiving level for messages for every account on server. User will be able to change this to any lower value by setting default modes as described in XEP-0136
section 2.4, but user will be allowed to set higher archiving level. If this property is set to higher value then default archiving level is set then this setting will be used as default archiving level setting.
Example in which we set required server message archiving level to
body
:

sess-man/plugins-conf/message-archive-xep-0136/required-store-method=body
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: