I am developing a chat application using XMPP framework. I can send and receive chat messages, and I want to transfer a file.
I used TURNSocket but it didn't work.
My code:
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
NSMutableArray *turnSockets=[NSMutableArray alloc] init];
}
return self;
}
- (void)viewDidLoad
{
XMPPJID *jid = [XMPPJID jidWithString:@"venkat.varra@gmail.com/gmail.9D2001A1"];
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
{
NSData *dataF = [[NSData alloc] initWithContentsOfFile:
[[NSBundle mainBundle] pathForResource:@"orange" ofType:@"png"]];
[socket writeData:dataF withTimeout:60.0f tag:0];
}
- (void)turnSocketDidFail:(TURNSocket *)sender
{
NSLog(@"TURN Connection failed!");
[turnSockets removeObject:sender];
}
When I run this program it always calles turnsocketDidFail method.
How can I achieve file transfers in a chat application using turn socket in iPhone? can any one help me? Thanks in advance