2012-01-16 48 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

相關問題