7

I'm attempting file transfer via XMPP on iOS using the XMPPFramework and OpenFire. The base of my code is from the following tutorial. I have a successful TurnSocket (XEP-0065: SOCKS5 Bytestreams) connection, but I can't work how to use it to send data. There are 2 considerations I have, both of which I am stuck on: 1. Calling [socket writeData] and 2. Using 'XEP-0096: SI File Transfer'.

Possible solution 1 - Calling [socket writeData] In my App delegate I have a didSucceed method. I can call [socket writeData] like this ...

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

    NSLog(@"TURN Connection succeeded!");

    [socket writeData:myData withTimeout:60.0f tag:0]; 
    [turnSockets removeObject:sender];
}

Updated 14th June : Is this correct? If so, how does the other user read the data? I have tried implementing

- (void)socket:(GCDAsyncSocket *)sock didReadData:(NSData *)data withTag:(long)tag

but it never gets called. How do I ensure it gets called?

Possible solution 2 - XEP-0096: SI File Transfer Do I need to use XEP-0096: SI File Transfer? If so, how do I use my successful connection within the XEP-0096 XML I need to form? The XEP-0096 docs imply there is a 'hash' attribute, but I don't know where this comes from.

e.g.

<iq type='set' id='offer1' to='receiver@jabber.org/resource'>
  <si xmlns='http://jabber.org/protocol/si' 
      id='a0'
      mime-type='text/plain'
      profile='http://jabber.org/protocol/si/profile/file-transfer'>
    <file xmlns='http://jabber.org/protocol/si/profile/file-transfer'
          name='test.txt'
          size='1022'
          hash='552da749930852c69ae5d2141d3766b1'
          date='1969-07-21T02:56:15Z'>
      <desc>This is a test. If this were a real 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>
Andy A
  • 4,191
  • 7
  • 38
  • 56
  • The `hash` is the MD5 of the file content. See Section 3 of XEP-0096. – Flow Jun 13 '12 at 19:36
  • Thanks for your response Flow. However, even if I put the hash in there, I don't quite understand how sending this stanza will begin a file transfer. I presume I need to use the socket somehow? – Andy A Jun 18 '12 at 11:04
  • @AndyA, were you eventually able to figure it out? If so would you mind sharing how you got it to work? – Ravindranath Akila Sep 13 '13 at 03:08
  • I didn't figure it out, no. I haven't worked on this project for over a year now I'm afraid. – Andy A Sep 13 '13 at 08:20

1 Answers1

1

Use XEP-0096 for FileTransfer instead of XEP-0065 it works fine with the IOS only , for successful transfer you need the current resource id of the receiver like user@jabber.com/2526318749013466431, to make the connection with proxy IP and port of the jabber server

Rohit Pathak
  • 359
  • 4
  • 16