2011-12-05 24 views
9

我想使用TURNSocket在兩個用戶之間傳輸文件。如何在ios中的XMPPFramework的TURNSocket中連接成功時接收文件?

用戶1:(iphone sumulator) 用戶2:(星火用戶)

現在套接字連接,我想將文件從用戶2通過星火發送到用戶1。和iPhone sumulator可以收到這些消息:

<iq xmlns="jabber:client" id="P1J6b-29" to="[email protected]/75694fce" from="[email protected]/Spark 2.6.3"  type="set"> 
    <si xmlns="http://jabber.org/protocol/si" id="jsi_8334411215933911079" mime-type="image/png" 
     profile="http://jabber.org/protocol/si/profile/file-transfer"> 
    <file xmlns="http://jabber.org/protocol/si/profile/file-transfer" name="a2.png" size="12618"> 
     <desc>Sending file</desc> 
    </file> 
    <feature xmlns="http://jabber.org/protocol/feature-neg"> 
     <x xmlns="jabber:x:data" type="form"> 
     <field var="stream-method" type="list-single"> 
      <option> 
      <value>http://jabber.org/protocol/bytestreams</value> 
      </option> 
      <option> 
      <value>http://jabber.org/protocol/ibb</value> 
      </option> 
     </field> 
     </x> 
    </feature> 
    </si> 
</iq> 

我的XMPP Sending/Receving file in iphone sdk ...? 話題有關如何在didSucceed方法處理中看到了這些,但我不知道如何接收由星火用戶所發送的文件iphone求和器。最後

- (void)writeData:(NSData *)data 
    withTimeout:(NSTimeInterval)timeout 
      tag:(long)tag; 

,關閉套接字:

然後,在你didSucceed實現,發送數據中傳遞的插座上,用

- (void)disconnectAfterWriting; 

那麼如何編寫接收這個方法或其他文件?

- (void)turnSocket:(TURNSocket *)sender didSucceed:(GCDAsyncSocket *)socket { 
    // Where is the NSData that can be find to used in writeData method ? 
} 
+0

嗨,尼爾,你有這個工作嗎? –

回答

1

嘗試FastSocket https://github.com/dreese/fast-socket。對於iPhone或服務器之間的TCP連接來說最好。請仔細閱讀文檔(尤其是單元測試),以獲取有關如何使用它的詳細說明。您需要知道每個連接到對方所需的設備的IP地址。

相關問題