0
我想构建一个简单的Jabber客户端。 我已经下载了这个示例项目,它使用xmpp框架https://github.com/funkyboy/Building-a-Jabber-client-for-iOS 我正在iOS模拟器中运行它。我在本地安装了Openfire,以便我可以与登录到iChat的用户进行交互。iPhone Jabber/XMPP客户端...“TURN连接失败”
不幸的是,该应用程序只有收到消息。它发送错误消息“TURN Connection failed!”失败。
这是代码尝试连接:
- (void)viewDidLoad
{
[super viewDidLoad];
self.tView.delegate = self;
self.tView.dataSource = self;
[self.tView setSeparatorStyle:UITableViewCellSeparatorStyleNone];
messages = [[NSMutableArray alloc ] init];
JabberClientAppDelegate *del = [self appDelegate];
del._messageDelegate = self;
[self.messageField becomeFirstResponder];
XMPPJID *jid = [XMPPJID jidWithString:@"[email protected]"];
NSLog(@"Attempting TURN connection to %@", jid);
TURNSocket *turnSocket = [[TURNSocket alloc] initWithStream:[self xmppStream] toJID:jid];
[turnSockets addObject:turnSocket];
[turnSocket startWithDelegate:self delegateQueue:dispatch_get_main_queue()];
[turnSocket release];
}
而且那些被称为成功/失败的方法:
- (void)turnSocket:(TURNSocket *)sender didSucceed:(GCDAsyncSocket *)socket
{
NSLog(@"TURN Connection succeeded!");
NSLog(@"You now have a socket that you can use to send/receive data to/from the other person.");
[turnSockets removeObject:sender];
}
- (void)turnSocketDidFail:(TURNSocket *)sender
{
NSLog(@"TURN Connection failed!");
[turnSockets removeObject:sender];
}
任何人都可以请帮助? 谢谢。
请您指出一些问题吗?我只找到了关于如何启动连接的文档 - 无论如何发送消息。非常感谢你。 –
结果不需要TURN - 错误与无法发送消息无关。我将sendMessage方法移至App Delegate,并开始工作。我不知道为什么。但它的工作。 –
@Joe: - 您能否介绍一下iOS中的集成XMPP,任何链接或文档?我对此很失败。 – iOSAppDev