RTMFP, where did all my neighbors go?


So while RTMFP is great for peer to peer connections, it does have some considerations that you need to take into account when using it. The biggest, knowing when peers connect and disconnect to the app.

When a peer connects, the app will receive a NetStatusEvent. The event’s info.code will be a “NetGroup.Neighbor.Connect”. You can use the info.neighbor as a unique identifier for the connected peer.

The nice thing, is if a peer comes in late to the p2p party, as soon as a peer sends a message that is received by yours, then the connect event will be fired. So you’ll always have a list of peers that have connected to your client.

When a peer needs to disconnect, it should call the NetGroup’s close() method. This will send out a packet letting all other peers know that it has disconnected.

The interesting thing is, this is RTMFP, so not all packets will get to all peers. So what happens if your client doesn’t receive the disconnect packet? How do you know that your list of connected peers isn’t stale? Good question. One I don’t yet have an answer to. So if any of you do, please let me know.

[GARD]


One response to “RTMFP, where did all my neighbors go?”

  1. Hey, I stumbled over that problem too. That’s really an issue. You could implement a keepalive message for you connected peers on top of a p2p connection, asking the otherside to ack existence and if not acked timeout the peer. It adds some overhead but it at least gives you more confidence in your peer list if you depend on it.

Leave a Reply