automatically share files to a new group member

43 views
Skip to first unread message

Andy Woods

unread,
Nov 16, 2013, 9:13:24 AM11/16/13
to cocoo...@googlegroups.com
Sorry for the many emails!

I'm having a hard time figuring out how to share existing shared objects with new group members.  I thought to 'shareWithAll' from the lead device each time a new member is detected but this, as far as I am aware, creates multiple copies of the objects and, in fact, the new group members receive nothing.  This is painful!!

Many thanks,
Andy.

Jesse Warden

unread,
Nov 16, 2013, 9:20:43 AM11/16/13
to cocoo...@googlegroups.com
I had the same problem and wasn't sure if it was me or the library.

I basically created a unique hash of a "file", which could be anything really (SO, ByteArray, File, etc). I then query everyone who connects if they have a list of those hashes. If they don't, I then send to them. It's hard to remember but I believe the shareWithAll has no way to verify if they actually have the file, it just immediately starts sharing it, hence the need for a few messages + ACK's up front to verify if they actually have the file or not.


--
You received this message because you are subscribed to the Google Groups "Cocoon P2P" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cocoon-p2p+...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Andy....@xperiment.mobi

unread,
Nov 16, 2013, 9:25:33 AM11/16/13
to cocoo...@googlegroups.com
Thanks!  As I only ever share 2 files with each device I think I will trying sending the objectMetaData along with the 'room to connect to' info, then reconstruct the objectMetaData and request these files.

I can't send messages to specifc devices!  Doesn't work... going a bit crazy with AS3's NetGroup feature..


Mobile: +41 7862 2719

This email and any files transmitted with it are confidential and intended solely for the use of the individual or entity to whom they are addressed. If you have received this email in error please notify the system manager. This message contains confidential information and is intended only for the individual named. If you are not the named addressee you should not disseminate, distribute or copy this e-mail. Please notify the sender immediately by e-mail if you have received this e-mail by mistake and delete this e-mail from your system. If you are not the intended recipient you are notified that disclosing, copying, distributing or taking any action in reliance on the contents of this information is strictly prohibited.


--
You received this message because you are subscribed to a topic in the Google Groups "Cocoon P2P" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/cocoon-p2p/PNWHysX6vXk/unsubscribe.
To unsubscribe from this group and all its topics, send an email to cocoon-p2p+...@googlegroups.com.

Jesse Warden

unread,
Nov 16, 2013, 9:35:15 AM11/16/13
to cocoo...@googlegroups.com
If you take it from a high level point of view, to support device to device messaging, you need to manage the actual "user list" yourself. As soon as someone connects, everyone retains a reference to them in that list. You setup a long ping just in case NetGroup fails to give you a disconnect. I had one situation where it didn't, and my code got all gnarly. Depending on a dependable ping/pong system helped me easily verify devices were in fact connected, and that each device was unique.

Second, I went with the whole send/ACK system. Every message that every device sends, whether to 1 device or many, expects an ACK back. If it does not receive an ACK back, it assumes the message failed to deliver. This made debugging very easy as I found Cocoon/NetGroup extremely reliable and my code not.

Third, once you have a sure fire way to send messages, and you can verify people are online or not, you can then start managing users. When a new person comes onto the group, you can shove them in a user list that you can iterate ping/pongs on. More importantly, though, every device has an opportunity to "bring them up to speed" as it were. Missing data, files, state, whatever. The only challenge here is you need to ensure if 3 devices offer to send a file, you need to ACK "no thank you" for 2 of them. If you're used to creating asynchronous services, this shouldn't be a challenge, but it is a pain to debug unless you have some visual thing to see what's going on on the various devices.

Fourth, once people are up to speed, and you've got a solid way to send a device 50 file offer requests with the knowledge that it'll ignore 49 of them, you can then begin the laborious process of writing code that works atop NetGroup to do that. For whatever reason the share functions did exactly what you said for me as well, and I couldn't figure out why I was getting 2 sends, etc., so I built my own file share atop the message/ACK system by sending small chunks of the file at a time. This was much more dependable, and easy to debug, it was just a ton of code.

Andy....@xperiment.mobi

unread,
Nov 16, 2013, 9:46:15 AM11/16/13
to cocoo...@googlegroups.com
thanks for the detailed discussion.  Much appreciated.

I ponder if some of the weirdness is due to me developing on just one machine / netgroup communicating within a device across two+ instances of a programme.  

cheers,
Andy.


Mobile: +41 7862 2719

This email and any files transmitted with it are confidential and intended solely for the use of the individual or entity to whom they are addressed. If you have received this email in error please notify the system manager. This message contains confidential information and is intended only for the individual named. If you are not the named addressee you should not disseminate, distribute or copy this e-mail. Please notify the sender immediately by e-mail if you have received this e-mail by mistake and delete this e-mail from your system. If you are not the intended recipient you are notified that disclosing, copying, distributing or taking any action in reliance on the contents of this information is strictly prohibited.


Jesse Warden

unread,
Nov 16, 2013, 9:49:10 AM11/16/13
to cocoo...@googlegroups.com
Every single group member gets a unique ID, so you should technically be able to run multiple applications on the machine and have them work fine... but I can't remember, hah, sorry.
Reply all
Reply to author
Forward
0 new messages