Closed lharder closed 3 years ago
Great suggestions! Thank you. I've included both of them and will do a new release.
By the way: Why not strip away the initial part of the string and only return the additional data? The client would have to do that otherwise right?
Yes, you are right - by all means :o) I have added that line of code:
Great, thanks!
Hi Britzl,
I have used your defnet library to discover hosts in a given network. It turned out that for me, the typical usecase was a little different, so I use some changes in a fork of your code. If you feel that they are useful, I would be glad if you considered them for the defnet upstream version:
If I am not mistaken, you stop the discovering process after detecting the first remote host. I would prefer to allow for more than just a single host to communicate with the player. With the callback function, the application can stop the discovery process at any time it sees fit, but this change allows for finding more than one peer if needed.
When searching for peers, you send a string to identify the type of host you wish to discover. Typically, to me, that would be the name/id of the game. However, I find it useful for every peer to be able to include some unique data, as well (e.g. each player's individual callsign). So instead of a test for equality of the id/name string, it is more flexible to check if the transmitted string only starts with the right string. That way, it can contain additional data that can then be evaluated by the application in the callback method.
To me, these trivial changes have been very helpful. Please let me know what you think.
Regards, Lutz
p2p_discovery.lua.zip