Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change request: 1. multiple hosts discoverable, 2. provide individual host info on discovery #8

Closed
lharder opened this issue Mar 18, 2021 · 4 comments

Comments

@lharder
Copy link

lharder commented Mar 18, 2021

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:

  1. 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.

  2. 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

@britzl britzl closed this as completed in 91ca073 Mar 18, 2021
@britzl
Copy link
Owner

britzl commented Mar 18, 2021

Great suggestions! Thank you. I've included both of them and will do a new release.

@britzl
Copy link
Owner

britzl commented Mar 18, 2021

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?

@britzl britzl reopened this Mar 18, 2021
@lharder
Copy link
Author

lharder commented Mar 19, 2021

Yes, you are right - by all means :o)
I have added that line of code:

p2p_discovery.lua.zip

@britzl
Copy link
Owner

britzl commented Mar 19, 2021

Great, thanks!

@britzl britzl closed this as completed Mar 19, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants