message

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Nov 24, 2022 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrInvalidMessage is return if the message is invalid
	ErrInvalidMessage = errors.New("invalid message")
	// ErrUndefinedMessage is return if the message is not defined
	ErrUndefinedMessage = errors.New("undefined message")
	// ErrFullChannel is returned if the message channel is full
	ErrFullChannel = errors.New("full channel")
)
View Source
var (
	ErrOldMessage             = errors.New("old message")
	ErrBadMsg                 = errors.New("bad message")
	ErrInvalidStateTransition = errors.New("invalid state transition")
	ErrDupMsg                 = errors.New("duplicate message")
)
View Source
var (
	ErrNotEchoMsg    = errors.New("not a echo message")
	ErrDifferentHash = errors.New("different hash")
)
View Source
var (
	ErrDupMessage = errors.New("duplicate message")
	ErrNotYours   = errors.New("not yours")
)

Functions

This section is empty.

Types

type EchoMessage

type EchoMessage interface {
	proto.Message
	types.Message
	// GetEchoMessage() return the message to broadcast in echo protocol
	GetEchoMessage() types.Message
}

Message defines the message interface

type EchoMsgMain

type EchoMsgMain struct {
	types.MessageMain
	// contains filtered or unexported fields
}

func NewEchoMsgMain

func NewEchoMsgMain(next types.MessageMain, pm types.PeerManager) *EchoMsgMain

func (*EchoMsgMain) AddMessage

func (t *EchoMsgMain) AddMessage(senderId string, msg types.Message) error

NOTE: Avoid duplicate messages from the same peer should be handled in the caller

type MsgChans

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

func NewMsgChans

func NewMsgChans(bufferLen uint32, ts ...types.MessageType) *MsgChans

func (*MsgChans) Pop

func (*MsgChans) Push

func (m *MsgChans) Push(msg types.Message) error

type MsgMain

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

func NewMsgMain

func NewMsgMain(id string, peerNum uint32, listener types.StateChangedListener, initHandler types.Handler, msgTypes ...types.MessageType) *MsgMain

func (*MsgMain) AddMessage

func (t *MsgMain) AddMessage(senderId string, msg types.Message) error

func (*MsgMain) GetHandler

func (t *MsgMain) GetHandler() types.Handler

func (*MsgMain) GetState

func (t *MsgMain) GetState() types.MainState

func (*MsgMain) Start

func (t *MsgMain) Start()

func (*MsgMain) Stop

func (t *MsgMain) Stop()

type Peer

type Peer struct {
	Id       string
	Messages map[types.MessageType]types.Message
}

func NewPeer

func NewPeer(id string) *Peer

func (*Peer) AddMessage

func (p *Peer) AddMessage(msg types.Message) error

func (*Peer) GetMessage

func (p *Peer) GetMessage(t types.MessageType) types.Message

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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