I have implemented xmpp using robbiehanson xmpp example. I am able to chat and also able to send images. The images which i am sending are converted to nsdata and further converted to Base64String, and later sending the string with
[self.xmppStream sendElement:message];
This way if the size of image is small i am able to send that instantly but if the size of images is bigger the two xmpp user gets disconnected and the file is not transferred. Same thing happens with video and audio. Though i am able to compress the images using
UIImageJPEGRepresentation(image,0.005);
But how to send the video and audio as the size would obviously be big. I have read documents on XEP - 0065 and XEP - 0096 but not able to implement it in a proper way. Please let me know why do the users gets disconnected, why i am not able to transfer heavy files using base64 and also share the code which would help me to transfer video and audio.
Would really appreciate you help.
While XMPP allow to transfer small amount of binary data, it is recommended to share large files or video/audio streams "out of band" and use XMPP as signaling protocol - you should just send http:// or rtp:// link, and your buddy's client will download it, or start playing audio/video from given stream. You can send that link in any form, but there are some "draft standard" XMPP extensions, which allow to get compatibility with existing clients:
<message />
element.So, if you just want to share file - share it via any existing file sharing service and send URL as described in the first XEP. If you want to build large service or VOIP application - use SI or Jingle. But no one stop you to create your own XMPP extension, which may be simpler to implement. Here is a custom XMPP extension, which was developed not by XMPP community, but accepted by XSF as experimental, you can check it too.
Even I am not sending the image directly to xmpp because it takes a lot time.
In my project I message can be string and it can be image and I found there is only one method to send message i.e..
So for sending the image First I am converting it to base64 then uploading it to my server and getting the URL for that image from server. Once we get the URL just pass that URL in Above method.
Problem here I was facing was how to segregate normal messages and URL (Images)
So for sending normal text I am directly sending it above function but for sending URL I am sending the nsdictionary i.e. I am converting nsdictionary to string and sending it in above function
For segregating normal message and Image in -
messages is my model class you can use simply use nsstring for testing purpose.
After this just use any open source project for downloading the image or perform lazy loading on your own.
Hope this will help you :)