2015-11-05 51 views
0

參考此我正在實施羣聊配置。XMPPFramework IOS - 實現MUC

XMPPFramework - Implement Group Chat (MUC)

但是作爲參與者,而不是主持人,我無法獲得成員列表。我嘗試閱讀多個堆棧答案,要求實現'muc#roomconfig_getmemberlist',但是XMPPRoom的fetchconfiguration委託沒有在回調中提供此字段值。

任何人都可以建議,這是實現這個確切的方式也如何獲取成員列表。

回答

0

這是默認在服務器上啓用配置,所以只需不需要設置,我們必須定製服務器才能讓成員離線並離開房間。因此可以像其他聊天應用程序成員一樣顯示。

1

創建使用

/** 
This fuction is used to setup room with roomId 
*/ 
-(void)setUpRoom:(NSString *)ChatRoomJID 
{ 
    if (!ChatRoomJID) 
    { 
     return; 
    } 
    // Configure xmppRoom 
    XMPPRoomMemoryStorage *roomMemoryStorage = [[XMPPRoomMemoryStorage alloc] init]; 

    XMPPJID *roomJID = [XMPPJID jidWithString:ChatRoomJID]; 

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

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

    NSXMLElement *history = [NSXMLElement elementWithName:@"history"]; 
    [history addAttributeWithName:@" maxchars" stringValue:@"0"]; 
    [xmppRoom joinRoomUsingNickname:xmppStream.myJID.user 
          history:history 
          password:nil]; 


    [self performSelector:@selector(ConfigureNewRoom:) withObject:nil afterDelay:4]; 

} 

/** 
This fuction is used configure new 
*/ 
- (void)ConfigureNewRoom:(id)sender 
{ 
    [xmppRoom configureRoomUsingOptions:nil]; 
    [xmppRoom fetchConfigurationForm]; 
    [xmppRoom fetchBanList]; 
    [xmppRoom fetchMembersList]; 
    [xmppRoom fetchModeratorsList]; 

} 

創建使用這兩種委託的方法,你可以很容易地維護用戶的列表XMPP房間

- (void)xmppRoom:(XMPPRoom *)sender occupantDidJoin:(XMPPJID *)occupantJID withPresence:(XMPPPresence *)presence 


- (void)xmppRoom:(XMPPRoom *)sender occupantDidLeave:(XMPPJID *)occupantJID withPresence:(XMPPPresence *)presence 

的房間內使用委託方法後XMPP房間加入到MUC

+0

謝謝Samanvith,我可以得到這些代表,因此不需要在服務器的設置配置中將其設置爲'muc#roomconfig_getmemberlist',因爲它默認在服務器中爲ON。謝謝你的信息。 –