2012-01-16 18 views
2

我使用openfire作为xmpp服务器,并且想通过Turnsocket传输文件。XMPPFramework - TURNSocket无法接收我自己发送的数据?

的Openfire的(本地)配置:

xmpp.auth.anonymous    true 
xmpp.domain      local 
xmpp.enabled      true 
xmpp.externalip     proxy.local, 192.168.1.101, 127.0.0.1 
xmpp.proxy.enabled     true 
xmpp.proxy.port     7777 
xmpp.proxy.transfer.required  false 
xmpp.server.socket.active   true 
xmpp.session.conflict.limit  0 
xmpp.socket.ssl.active    true 

我测试在本地环境中的文件传输,一个用户是通过模拟器(发件人)登录,其他用户通过设备(已登录的iPod,接收器)。

  1. TURNSocket.m(均改变),更改代理

    + (void)initialize { 
        ... 
        proxyCandidates = [[NSMutableArray alloc] initWithObjects:@"local", nil]; 
        ... 
    } 
    
  2. 配置上都发送者和接收者

    - (BOOL)xmppStream:(XMPPStream *)sender didReceiveIQ:(XMPPIQ *)iq { 
    
        ... 
    
        if ([TURNSocket isNewStartTURNRequest:iq]) { 
    
         NSLog(@"IS NEW TURN request Receive.. TURNSocket.................."); 
    
         TURNSocket *turnSocket = [[TURNSocket alloc] initWithStream:xmppStream incomingTURNRequest:iq]; 
         [turnSockets addObject:turnSocket]; 
         [turnSocket startWithDelegate:self delegateQueue:dispatch_get_main_queue()]; 
         [turnSocket release]; 
        } 
        return YES; 
    } 
    
  3. 建立和呼叫TURNSocket(发件人)

    TURNSocket *turnSocket = [[TURNSocket alloc] initWithStream:[self xmppStream] toJID:user.primaryResource.jid]; 
    [turnSockets addObject:turnSocket]; 
    [turnSocket startWithDelegate:self delegateQueue:dispatch_get_main_queue()]; 
    [turnSocket release]; 
    
  4. didSucceed称为两者(发送者和接收者)

    - (void)turnSocket:(TURNSocket *)sender didSucceed:(GCDAsyncSocket *)socket { 
    

    }

  5. 发送文件?发件人

    - (void)turnSocket:(TURNSocket *)sender didSucceed:(GCDAsyncSocket *)socket { 
    
        NSData *dataF = [[NSData alloc] initWithContentsOfFile: 
                [[NSBundle mainBundle] pathForResource:@"a1" ofType:@"png"]]; 
    
        [socket writeData:dataF withTimeout:60.0f tag:0]; 
    } 
    

    OR:收到数据吗? (接收器)

    - (void)turnSocket:(TURNSocket *)sender didSucceed:(GCDAsyncSocket *)socket { 
    
        NSData *dataF = [[NSData alloc] init]; 
    
        [socket readDataToData:dataF withTimeout:30.0 tag:0]; 
        NSLog(@"dataF: %d", [dataF length]); // dataF: 0 
    } 
    

有谁知道出了什么问题?

非常感谢!

+0

嗨尼尔。你在这里有什么进展? – 2012-04-13 09:17:51

+0

在这方面的任何更新? – Neelesh 2014-01-10 11:00:46

+0

你是如何转移文件的? – 2014-03-24 08:51:16

回答

-1

要设置外部IP地址,您需要使用xmpp.proxy.externalip而不是xmpp.externalip

相关问题