単純なJabberクライアントを構築しようとしています。xmpp -frameworkhttps ://github.com/funkyboy/Building-a-Jabber-client-for-iOSを使用するこのサンプルプロジェクトをダウンロード しました。iOSシミュレーターで実行しています。Openfireをローカルにインストールして、iChatにログインしているユーザーとやり取りできるようにしました。
残念ながら、アプリはメッセージのみを受信します。メッセージの送信に失敗し、「TURN接続に失敗しました!」というエラーが表示されます。
これは接続しようとしているコードです:
- (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:@"user@server.local"];
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];
}
誰か助けてもらえますか?ありがとうございました。