Add client related info when sending files

85 views
Skip to first unread message

Angel Todorov

unread,
Jun 6, 2015, 2:55:06 AM6/6/15
to eas...@googlegroups.com
Hi there,
I am using easyrtc_ft for transferring files between peers. From what I understood, when calling easyrtc_ft.buildFileSender from the sender's side, on the receiver's side the acceptRejectFileTransferCB callback is called, where acceptRejectFileTransferCB is first callback from the following method easyrtc_ft.buildFileReceiver(acceptRejectFileTransferCB, blobFileTransferAcceptor, receiveFileTransferStatusCB). So far so good.
In my application currently each peer can open a chat session, add some of the current room's participants and start chatting with them. Each chat session has unique id, which is send from the chat initiator every time he send a message. It allows on the recipient's side the right chat session to be either found or created. This approach allows me to keep correct chat sessions with the correct participants and chat chronology.
The issue I have got is when I decided to add file transfer to this flow - unlike the text exchange where I can use easyrtc.SendPeerMessage method and along with the text message I can add whatever client info I need (e.g. chat session, chat participants), when I call easyrtc_ft.buildFileSender, I cannot add specific sender info - the only unique id I can use is sender's easyrtcId, which in my case is not enough since I can have more than one chat sessions between two peers, but in different participants' configurations, and I want to send the file transfer request to the right chat session.

So my question is - how can I send additional sender's data when sending file transfer request? I assume this should be done from easyrtc_ft.buildFileSender, but I can't see how it could happened...

Regards,
Angel

Eric Davies

unread,
Jun 6, 2015, 9:33:24 PM6/6/15
to eas...@googlegroups.com
I see two options:
  1) Send a preceding message with the extra meta data, before you initiate the file transfer.
  2) Modify the easyrtc_ft code to include the extra information. The easyrtc_ft library was written over the course of two days, it works but it was really written to be small and quickly accomplished, not feature-full. If it doesn't do what you want, make your own copy of it and modify as needed; it's not part of the core webrtc API.


Angel Todorov

unread,
Jun 8, 2015, 2:48:34 AM6/8/15
to eas...@googlegroups.com
Hi Eric,
Thanks for answering,

Actually I initially considered the first option, since I don't want to tweak any easyrtc libraries. The problem I struggled with this path is that so called meta / extra data is received by PeerListener while the following files is received by acceptRejectFileTransferCB, where the only available identifier is still sender's easyrtcId. So I cannot see how to "glue" chat identifier send to the first callback with the sender's Id send by the second one.

As per the second option mentioned by you - not sure how to amend easyrtc_ft code so it can send required additional info to the receiver. Any hints in that direction will be appreciated.

Thanks in advance,
Angel

Eric Davies

unread,
Jun 9, 2015, 1:48:23 AM6/9/15
to eas...@googlegroups.com
Sounds like the second option is probably easier for you. I have to admit, it's the file sharing library is not the easiest code to follow with all the callbacks flying around.

Take a look at the files in the following gist. It's a hack of the data channel file sharing demo.

In the applications .js file, I've added a magicDataOut parameter  to the sendfile method.
In the applications .js file, I've added a magicDataIn parameter to the function that determines whether you accept or a reject a file.
And of course, the library has been extended to support these two parameters.

Note: I did not do anything with the file dropping code. That's just garden variety browser stuff so it shouldn't pose any problem to you.

Eric.

ROWLAND MWALE

unread,
Jun 9, 2015, 5:31:40 AM6/9/15
to eas...@googlegroups.com
Hi Angel,

I think you can use the sendPeerMessage() function to send files, as well as client info in the same way you'd in text messaging. Unless you want to make use of Data Channels, you dont really need the Easyrtc_ft.js library.

ie
easyrtc.sendPeerMessage(easyrtcid,"blob", {"data": imagedata, "type":'image,"sender":myeasyrtcid,"sendername":easyrtc.username'},
     function(ackMsg) {
         
     });

Eric Davies

unread,
Jun 10, 2015, 12:41:57 AM6/10/15
to eas...@googlegroups.com
Hmm, I like Rowland's solution. A simple one liner. As long as you don't mind pushing the file contents through your server (sometimes there are privacy concerns with that, as well as the usual bandwidth issues of course).

Angel Todorov

unread,
Jun 10, 2015, 3:49:25 AM6/10/15
to eas...@googlegroups.com
Hi Rowland,
Thanks for elaborating on the topic. Still not quite sure and need to assess the following (possible) side effects if go with your proposal:
- Can I track file transfer progress - something I have got by receiveFileTransferStatusCB (see easyrtc_ft.buildFileReceiver)?
- Can I send relatively big files (e.g. 20, 30 MB)?
- Can I send multiple files at once and check their transfer progress (see first question)
- Is there anything received by function(ackMsg) in easyrtc.sendPeerMessage? I have got the impression that both callbacks in easyrtc.sendPeerMessage are never called...

Best Regards,
Angel

Angel Todorov

unread,
Jun 10, 2015, 3:50:56 AM6/10/15
to eas...@googlegroups.com
Hi Eric,
Thanks for the spared time for preparing the snippets.

I will look at the provided code snippet above and depending of the Rowland's answers I will decide how to go.

Best Regards,
Angel
Reply all
Reply to author
Forward
Message has been deleted
0 new messages