2016-08-03 81 views
0

我成功實現了使用Openfire和XMPP進行羣聊。如何檢索離線消息openfire XMPP?

現在,當用戶A向離線的用戶B發送消息時,所以當用戶B在線時,我如何從服務器檢索所有未讀/離線消息。

我做這個東西加入聊天室,但它從服務器獲取的所有消息:

- (void) getJoinRoom 
{ 
    XMPPRoomMemoryStorage *roomStorage = [[XMPPRoomMemoryStorage alloc] init]; 
    XMPPJID *roomJID = [XMPPJID jidWithString:chatWithUser]; 

    xmppRoom = [[XMPPRoom alloc] initWithRoomStorage:roomStorage 
               jid:roomJID 
             dispatchQueue:dispatch_get_main_queue()]; 

    [xmppRoom activate:self.xmppStream]; 
    [xmppRoom addDelegate:self 
      delegateQueue:dispatch_get_main_queue()]; 

    [xmppRoom joinRoomUsingNickname:self.xmppStream.myJID.user 
          history:nil 
          password:nil]; 
} 

如何抓那些離線消息?

回答

0

根據XMPP標準,只有一對一聊天消息纔有資格進行離線存儲,因此type =「groupchat」的消息從不存儲在XMPP服務器的離線存儲中。

根據MUC XEP如果用戶下線,它不再被視爲房間的參與者。所以當用戶上網時,他必須通過發送存在包到房間來加入房間。