network

package
v0.0.0-...-8886596 Latest Latest
Warning

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

Go to latest
Published: May 17, 2024 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AttachListener

func AttachListener(h host.Host, listener MessageReceiver)

func GetFirstConnectionToPeer

func GetFirstConnectionToPeer(host host.Host, pi peer.ID) *network.Conn

func SendMessageToPeer

func SendMessageToPeer(conn *network.Conn, msg *PlainOutboundMessage) error

Types

type EncryptedOutboundMessage

type EncryptedOutboundMessage struct {
	Recipient   peer.ID
	PrivKey     crypto.PrivKey
	ServiceName string
	ProtocolID  protocol.ID
	Payload     protobuf.Message
	Timeout     *time.Duration
}

func (*EncryptedOutboundMessage) GetProtocolID

func (m *EncryptedOutboundMessage) GetProtocolID() protocol.ID

func (*EncryptedOutboundMessage) GetRecipient

func (m *EncryptedOutboundMessage) GetRecipient() peer.ID

func (*EncryptedOutboundMessage) GetServiceName

func (m *EncryptedOutboundMessage) GetServiceName() string

func (*EncryptedOutboundMessage) GetTimeout

func (m *EncryptedOutboundMessage) GetTimeout() *time.Duration

func (*EncryptedOutboundMessage) Marshal

func (m *EncryptedOutboundMessage) Marshal() ([]byte, error)

type ListenerPhase

type ListenerPhase string
const (
	SetupTimeout  ListenerPhase = "setup-timeout"
	SetService    ListenerPhase = "set-service"
	ReserveMemory ListenerPhase = "reserve-memory"
	ReadBytes     ListenerPhase = "read-bytes"
)

type MessageReceiver

type MessageReceiver interface {
	GetServiceName() string
	GetProtocolID() protocol.ID
	GetReadTimeout() *time.Duration
	GetBufferSize() int
	HandleMessage(bytes []byte, pi peer.ID)
	HandleError(phase ListenerPhase, err error)
}

type OutboundMessage

type OutboundMessage interface {
	GetRecipient() peer.ID
	GetServiceName() string
	GetProtocolID() protocol.ID
	GetTimeout() *time.Duration
	Marshal() ([]byte, error)
}

type PlainOutboundMessage

type PlainOutboundMessage struct {
	Recipient   peer.ID
	ServiceName string
	ProtocolID  protocol.ID
	Payload     protobuf.Message
	Timeout     *time.Duration
}

func (*PlainOutboundMessage) GetProtocolID

func (m *PlainOutboundMessage) GetProtocolID() protocol.ID

func (*PlainOutboundMessage) GetRecipient

func (m *PlainOutboundMessage) GetRecipient() peer.ID

func (*PlainOutboundMessage) GetServiceName

func (m *PlainOutboundMessage) GetServiceName() string

func (*PlainOutboundMessage) GetTimeout

func (m *PlainOutboundMessage) GetTimeout() *time.Duration

func (*PlainOutboundMessage) Marshal

func (m *PlainOutboundMessage) Marshal() ([]byte, error)

Jump to

Keyboard shortcuts

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