【发布时间】:2014-04-27 22:55:23
【问题描述】:
我可以很好地接收来自其他客户端的消息,但我不确定是否可以发送消息。我看过一些代码,但我不确定该代码应该在哪里。在 XMPPStream.m 中?如果有,在哪里?
【问题讨论】:
标签: xcode xmpp xmppframework
我可以很好地接收来自其他客户端的消息,但我不确定是否可以发送消息。我看过一些代码,但我不确定该代码应该在哪里。在 XMPPStream.m 中?如果有,在哪里?
【问题讨论】:
标签: xcode xmpp xmppframework
将以下代码添加到您的 RootviewController.m 中:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
XMPPUserCoreDataStorageObject * currentUser = [[self fetchedResultsController] objectAtIndexPath:indexPath];
NSXMLElement *body = [NSXMLElement elementWithName:@"body"];
[body setStringValue:@"Hi"];
NSXMLElement *message = [NSXMLElement elementWithName:@"message"];
[message addAttributeWithName:@"type" stringValue:@"chat"];
[message addAttributeWithName:@"to" stringValue:currentUser.jidStr];
[message addChild:body];
[[[self appDelegate] xmppStream] sendElement:message];
}
【讨论】: