messenger

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: May 18, 2022 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (

	// MessageSizeMax is a soft maximum for network messages.
	MessageSizeMax = 1 << 25 // 32 MB

	// ErrReadTimeout must be used when receiving timeout while reading
	ErrReadTimeout = errors.Error("timed out reading response")

	// ErrInvalidatedMessageSender must be used when the message sender object created is no longer valid (connection has dropped)
	ErrInvalidatedMessageSender = errors.Error("message sender has been invalidated")
)

Variables

This section is empty.

Functions

This section is empty.

Types

type P2PMessenger

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

P2PMessenger is a libp2p messenger using protobufs and length delimited encoding

func NewP2PMessenger

func NewP2PMessenger(ctx context.Context, host host.Host, p2pTimeout time.Duration,
	handler func(ctx context.Context, peer libp2pPeer.ID, protoc protocol.ID, msg *pb.P2PEnvelope) (*pb.P2PEnvelope, error)) *P2PMessenger

NewP2PMessenger returns a libp2p-messenger

func (*P2PMessenger) Init

func (mes *P2PMessenger) Init(protocols ...protocol.ID)

Init initiates listening to given set of protocol streams

func (*P2PMessenger) SendMessage

func (mes *P2PMessenger) SendMessage(ctx context.Context, p libp2pPeer.ID, pmes *pb.P2PEnvelope, protoc protocol.ID) (*pb.P2PEnvelope, error)

SendMessage sends out a request

Jump to

Keyboard shortcuts

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