openfire 消息回执

参考了: http://blog.csdn.net/t8500071/article/details/13094933

我底层使用的是smack ,最后根据资料使用到了android的jar

 

自动回执代码:

// add delivery receipts  
pm.addExtensionProvider(DeliveryReceipt.ELEMENT, DeliveryReceipt.NAMESPACE,  
			        new DeliveryReceipt.Provider());  
pm.addExtensionProvider(DeliveryReceiptRequest.ELEMENT, DeliveryReceipt.NAMESPACE,  
			        new DeliveryReceiptRequest.Provider()); 			
xmpp.login(user.getUserAccount(), user.getPassword());
DeliveryReceiptManager.getInstanceFor(xmpp).enableAutoReceipts();

 关于内容在上面有参考网站上有解释。如果只是简单的设置DeliveryReceiptManager.getInstanceFor(xmpp).enableAutoReceipts();(自动回执)

是无法成功,因为它们共用一个Provider

所以要加上:

ProviderManager pm = ProviderManager.getInstance();  
			// add delivery receipts  
pm.addExtensionProvider(DeliveryReceipt.ELEMENT, DeliveryReceipt.NAMESPACE,  
			        new DeliveryReceipt.Provider());  
pm.addExtensionProvider(DeliveryReceiptRequest.ELEMENT, DeliveryReceipt.NAMESPACE,  
			        new DeliveryReceiptRequest.Provider()); 

 

 

设置消息回执请求为:

DeliveryReceiptManager.addDeliveryReceiptRequest(Message);

 就是在发送消息之前需要添加此行代码,简单的说就是发送回执请求

 

需要使用到关键jar在附件中

你可能感兴趣的:(openfire)