Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Done ¶
type Done chan<- interface{}
Done is channel used to singal the termination of the service.
type OnPeerStoreChange ¶
type OnPeerStoreChange func(i int)
OnPeerStoreChange is a function that is executed everytime a peer is added to the store.
type Peer ¶
type Peer struct { Name string // Name is the peers name. IPAddress net.IP // IPAddress is the net.IP address of the peer. Port int // Port is the network port where the peer will receive connections. Address net.Addr // Address is the resolved TCP Address of the peer IP+Port. Me bool // Me identify the peer as the local peer. }
Peer defines a network peer that can send and receive files.
type PeerList ¶
type PeerList struct { widget.List TransferRequest Parent fyne.Window // contains filtered or unexported fields }
PeerList is an extended version of widget.List where is uses a store to hold the list items, has a callback to the ouside and has is own layout.
type PeerServer ¶
type PeerServer struct {
// contains filtered or unexported fields
}
PeerServer defines the server that registers the peer and discover other peers. It wrappes the logic for zeroconf.
func NewServer ¶
func NewServer(name string, port int, store *PeerStore) *PeerServer
NewServer will create a new peer server instace.
The name to be added to the instance name, the port is the port number used for the TCP connections from where the files will be transferred.
func (*PeerServer) Run ¶
func (s *PeerServer) Run(ctx context.Context, done Done) error
Run will start the Server that will register the peer and start looking for peers on the local network with zeroconf.
Each peer that is discovered will be added to the peer store.
If there is an error, it can be because the server couldn't make the registrations, the server listener couldn't start or fail to start the discovery process.
type PeerStore ¶
type PeerStore struct { OnPeerStoreChange // contains filtered or unexported fields }
PeerStore is a thread-safe store that allows to store and retrieve peers and also get notification when the content of the store changes.
func (*PeerStore) Add ¶
Add will append a peer to the existing list of peers.
It returns the index where the peer whas stored.
After the peer gets added the function OnPeerStoreChanged is executed.