Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use a TurnSocket (XEP-0065: SOCKS5 Bytestreams) connection? XEP-0096: SI File Transfer? [socket writeData]?

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='[email protected]/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>
like image 258
Andy A Avatar asked Jun 13 '12 15:06

Andy A


1 Answers

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 [email protected]/2526318749013466431, to make the connection with proxy IP and port of the jabber server

like image 131
Rohit Pathak Avatar answered Sep 20 '22 05:09

Rohit Pathak