2016-05-17 69 views

回答

2

這就是XMPP多用戶聊天的工作原理。多用戶聊天規範是基於狀態的。當你離線時,你不是房間的佔有者。

0

創建房間後設置您的XMPP間持續使用下面的代碼...

-(void)xmppRoomDidJoin:(XMPPRoom *)sender { 
    NSLog("I did join."); 
    [sender fetchConfigurationForm]; 
} 

-(void)xmppRoom:(XMPPRoom *)sender didFetchConfigurationForm:(NSXMLElement *)configForm { 

    NSXMLElement *newConfig = [configForm copy]; 

    NSArray *fields = [newConfig elementsForName:@"field"]; 

    for (NSXMLElement *field in fields) { 

     NSString *var = [field attributeStringValueForName:@"var"]; 
     // Make Room Persistent 

     if ([var isEqualToString:@"muc#roomconfig_persistentroom"]) { 

     [field removeChildAtIndex:0]; 
     [field addChild:[NSXMLElement elementWithName:@"value" stringValue:@"1"]]; 

     } 
    } 

    [sender configureRoomUsingOptions:newConfig]; 

} 

到時候如果房間的主人下線是時間XMPP客房與所有成員存在