在iOS Chat App中由xmpp发送给朋友的文件和图像

时间:2014-07-23 06:16:25

标签: ios xmpp chat

您正在开发xmpp clint chat App。我想发送文件给朋友,但它发送失败。 我正在使用以下代码..请帮助我任何一个

- (void)sendToOtherDevice:(NSData *)fileData receiverJid:(NSString *)receiverJid {

            XMPPJID *JID = [XMPPJID jidWithString:[NSString stringWithFormat:@"%@",receiverJid]];
            NSLog(@"%@",[JID full]);
            NSLog(@"fileData lenght == %d",fileData.length);
            NSLog(@"Attempting TURN connection to %@", JID);

            [TURNSocket setProxyCandidates:[NSArray arrayWithObjects:JID.domain, nil]];
            TURNSocket *turnSocket = [[TURNSocket alloc] initWithStream:[self xmppStream] toJID:JID];
            [turnSockets addObject:turnSocket];
            [turnSocket startWithDelegate:self delegateQueue:dispatch_get_main_queue()];
}

-(void)turnSocket:(TURNSocket *)sender didSucceed:(GCDAsyncSocket *)socket
        {
        //    [socket writeData:photoData withTimeout:60.0f tag:0];

            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];

}

0 个答案:

没有答案