0

我可以连接到本地服务器,也可以连接到 google talk 并在 iphone 聊天客户端上显示好友和聊天,但是当我尝试获取本地服务器的好友列表时,它返回 0。

- (void)xmppStream:(XMPPStream *)sender didReceivePresence:(XMPPPresence *)presence {

// a buddy went offline/online

NSString *presenceType = [presence type]; // online/offline
NSString *myUsername = [[sender myJID] user];
NSString *presenceFromUser = [[presence from] user];

if (![presenceFromUser isEqualToString:myUsername]) 
{

 if ([presenceType isEqualToString:@"available"]) {

 [_chatDelegate newBuddyOnline:[NSString stringWithFormat:@"%@@%@", presenceFromUser, @"ip address"]];

} else if ([presenceType isEqualToString:@"unavailable"]) {

 [_chatDelegate buddyWentOffline:[NSString stringWithFormat:@"%@@%@", presenceFromUser, @"ip address"]];

}

}
}

这里的ip地址是我的服务器名请帮忙!

请帮我!!!

4

1 回答 1

0

它只告诉你某人何时上线或下线,根据此代码,任何好友何时上线 委托方法“newBuddyOnline”将被触发,当某人下线时,委托方法“buddyWentOffline”将被触发。您可以通过在连接到 xmpp 流后在线时将好友添加到数组来获取所有好友的列表

于 2013-08-02T09:37:12.243 回答