discover

package
v0.23.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 22, 2022 License: GPL-3.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrParameters      = errors.New("Failed to create new ExchangeProtocol, invalid parameters")
	ErrInvalidPeer     = errors.New("Peer object provided to ExchangeProtocol is Nil")
	ErrTopicNotCreated = errors.New("Lobby Topic has not been Created")
)

Functions

func OLC added in v0.18.2

func OLC(l *types.Location) string

OLC returns Open Location code

Types

type DiscoverProtocol

type DiscoverProtocol struct {
	// contains filtered or unexported fields
}

DiscoverProtocol handles Global and Local Sonr Peer Exchange Protocol

func New

func New(ctx context.Context, host host.HostImpl, cb config.CallbackImpl, options ...Option) (*DiscoverProtocol, error)

New creates new DiscoveryProtocol

func (*DiscoverProtocol) Close

func (p *DiscoverProtocol) Close() error

Close method closes the ExchangeProtocol

func (*DiscoverProtocol) Get

func (p *DiscoverProtocol) Get(sname string) (*types.Peer, error)

FindPeerId method returns PeerID by SName

func (*DiscoverProtocol) Put

func (p *DiscoverProtocol) Put(peer *types.Peer) error

Put method updates peer instance in the store

func (*DiscoverProtocol) Update

func (p *DiscoverProtocol) Update() error

Update method publishes peer data to the topic

type ErrFunc

type ErrFunc func() error

ErrFunc is a function that returns an error

type LobbyEvent

type LobbyEvent struct {
	ID   peer.ID
	Peer *types.Peer
	// contains filtered or unexported fields
}

LobbyEvent is either Peer Update or Exit in Topic

type Local

type Local struct {
	// contains filtered or unexported fields
}

Local is the protocol for managing local peers.

func (*Local) Publish

func (p *Local) Publish(data *types.Peer) error

Publish publishes a LobbyMessage to the Local Topic

type Option

type Option func(*options)

Option is a function that can be applied to ExchangeProtocol config

func DisableAutoPush

func DisableAutoPush() Option

DisableAutoPush disables the auto push of the Lobby for OLC

func WithInterval

func WithInterval(i time.Duration) Option

WithInterval sets the interval of the Topic for Local OLC

func WithLocation

func WithLocation(l *types.Location) Option

WithLocation sets the location of the Topic for Local OLC

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL