schollz / peerdiscovery

Pure-Go library for cross-platform local peer discovery using UDP multicast :woman: :repeat: :woman:
MIT License
638 stars 55 forks source link

Enable unlimit scanning and notify function #7

Closed oxzi closed 5 years ago

oxzi commented 5 years ago

Enabling unlimitted scanning by setting TimeLimit to a negative value and setting Notify to a function, consuming a Discovered struct, will let the peerdiscovery library run forever. Each discovery, regardless of wether known before or not, will be passed to the Notify function. This implementation is oriented by the observer pattern.

I needed the described change of the library for my use case. This enables scanning for new peers in the background and letting me decide if I want to establish a connection to those hosts.

Please give me a feedback, if this is helpful for you or this library at all?

schollz commented 5 years ago

This is awesome! I've always wanted to do this kind of thing but didn't know how! Thanks!

oxzi commented 5 years ago

Thanks for merging this PR and adding an example :-)