【问题标题】:How to receive the file when connecting success in TURNSocket Of XMPPFramework in ios?ios中XMPPFramework的TURNSocket连接成功时如何接收文件?
【发布时间】:2012-01-13 01:07:57
【问题描述】:

我想用TURNSocket在两个用户之间传输文件。

User1: (iphone sumulator) 用户 2:(Spark 用户)

现在套接字已连接,我想通过 Spark 从 User2 向 User1 发送文件。 iphone sumulator 可以收到这些消息:

<iq xmlns="jabber:client" id="P1J6b-29" to="User1@local/75694fce" from="User2@local/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方法中处理的主题,但我不知道如何接收Spark用户在iphone sumulator上发送的文件。

然后,在您的 didSucceed 实现中,在传入的套接字上发送数据,使用:

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

最后,关闭套接字:

- (void)disconnectAfterWriting;

那么如何编码以这种方法或其他方法接收文件?

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

【问题讨论】:

  • 嗨,尼尔,你让这个东西工作了吗?

标签: iphone ios file xmpp


【解决方案1】:

试试 FastSocket https://github.com/dreese/fast-socket。最好是 iPhone 或服务器之间的 TCP 连接。请同时阅读文档(尤其是单元测试)以获取有关如何使用它的非常详细的说明。您需要知道相互连接所需的每台设备的 IP。

【讨论】:

    猜你喜欢
    • 2014-06-24
    • 2012-02-11
    • 2012-05-05
    • 2016-05-31
    • 2013-05-06
    • 2015-05-03
    • 2015-01-01
    • 1970-01-01
    相关资源
    最近更新 更多