Add documentation, fix package local's name, add examples, and LICENSE
This commit is contained in:
parent
251638f59b
commit
6786d67033
8 changed files with 161 additions and 4 deletions
|
@ -1,4 +1,4 @@
|
|||
package broadcast
|
||||
package local
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
@ -34,7 +34,7 @@ var (
|
|||
ErrBroadcastSendBadSize = fmt.Errorf("broadcast message size must be > 0B and <= %dB", MaxUDPPacketSize)
|
||||
)
|
||||
|
||||
// Broadcast implements Seeker with local network broadcasting with IPv4 broadcasting
|
||||
// Broadcast implements Seeker with local network broadcasting via IPv4 broadcasting
|
||||
type Broadcast struct {
|
||||
listenAddr *net.UDPAddr
|
||||
bcastIPs []net.IP
|
||||
|
@ -66,7 +66,10 @@ func NewBroadcast(listenAddr *net.UDPAddr, bcastIPs []net.IP) (b *Broadcast, err
|
|||
return
|
||||
}
|
||||
|
||||
// Listen for incoming Send requests from other Broadcast implementations
|
||||
// Listen for incoming Send requests from other Broadcast implementations.
|
||||
// It is very likely that if this instance is listening on the same broadcast IP as one that
|
||||
// it is also sending from, that it will receive what it is sent. It is up to the user to
|
||||
// decide whether or not they care about receiving messages they are also sending.
|
||||
func (b *Broadcast) Listen(ctx context.Context, msgChan chan<- []byte) error {
|
||||
b.lconnLock.Lock()
|
||||
defer b.lconnLock.Unlock()
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
package broadcast
|
||||
package local
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
|
3
local/local.go
Normal file
3
local/local.go
Normal file
|
@ -0,0 +1,3 @@
|
|||
// Package local provides Seeker implementations that are designed to only work on
|
||||
// LAN interfaces.
|
||||
package local
|
Loading…
Add table
Add a link
Reference in a new issue