messenger

package
v0.0.0-...-cff1f21 Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2023 License: GPL-3.0 Imports: 34 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Messenger

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

func CreateMessenger

func CreateMessenger(pubKey *crypto.PublicKey, seedPeerMultiAddresses []string,
	port int, seedPeerOnly bool, msgrConfig MessengerConfig, needMdns bool, ctx context.Context) (*Messenger, error)

CreateMessenger creates an instance of Messenger

func (*Messenger) Broadcast

func (msgr *Messenger) Broadcast(message p2ptypes.Message, skipEdgeNode bool) (successes chan bool)

Broadcast broadcasts the given message to all the connected peers

func (*Messenger) BroadcastToNeighbors

func (msgr *Messenger) BroadcastToNeighbors(message p2ptypes.Message, maxNumPeersToBroadcast int, skipEdgeNode bool) (successes chan bool)

BroadcastToNeighbors broadcasts the given message to neighbors

func (*Messenger) ID

func (msgr *Messenger) ID() string

ID returns the ID of the current node

func (*Messenger) IsSeedPeer

func (msgr *Messenger) IsSeedPeer(pid string) bool

func (*Messenger) PeerExists

func (msgr *Messenger) PeerExists(peerID string) bool

PeerExists indicates if the given peerID is a neighboring peer

func (*Messenger) PeerURLs

func (msgr *Messenger) PeerURLs(skipEdgeNode bool) []string

PeerURLs returns the URLs of all peers

func (*Messenger) Peers

func (msgr *Messenger) Peers(skipEdgeNode bool) []string

Peers returns the IDs of all peers

func (*Messenger) Publish

func (msgr *Messenger) Publish(message p2ptypes.Message) error

Publish publishes the given message to all the subscribers

func (*Messenger) RegisterMessageHandler

func (msgr *Messenger) RegisterMessageHandler(msgHandler p2pl.MessageHandler)

RegisterMessageHandler registers the message handler

func (*Messenger) Send

func (msgr *Messenger) Send(peerID string, message p2ptypes.Message) bool

Send sends the given message to the specified peer

func (*Messenger) Start

func (msgr *Messenger) Start(ctx context.Context) error

Start is called when the Messenger starts

func (*Messenger) Stop

func (msgr *Messenger) Stop()

Stop is called when the Messenger stops

func (*Messenger) Wait

func (msgr *Messenger) Wait()

Wait suspends the caller goroutine

type MessengerConfig

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

MessengerConfig specifies the configuration for Messenger

func GetDefaultMessengerConfig

func GetDefaultMessengerConfig() MessengerConfig

GetDefaultMessengerConfig returns the default config for messenger, not necessary

type PeerNotif

type PeerNotif Messenger

func (*PeerNotif) ClosedStream

func (p *PeerNotif) ClosedStream(n network.Network, s network.Stream)

func (*PeerNotif) Connected

func (p *PeerNotif) Connected(n network.Network, c network.Conn)

func (*PeerNotif) Disconnected

func (p *PeerNotif) Disconnected(n network.Network, c network.Conn)

func (*PeerNotif) Listen

func (p *PeerNotif) Listen(n network.Network, _ ma.Multiaddr)

func (*PeerNotif) ListenClose

func (p *PeerNotif) ListenClose(n network.Network, _ ma.Multiaddr)

func (*PeerNotif) OpenedStream

func (p *PeerNotif) OpenedStream(n network.Network, s network.Stream)

Jump to

Keyboard shortcuts

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