protocol

package
v0.14.0 Latest Latest
Warning

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

Go to latest
Published: Jun 5, 2022 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AGENCY_NONE   uint = 0
	AGENCY_CLIENT uint = 1
	AGENCY_SERVER uint = 2
)
View Source
const (
	// This is completely arbitrary, but the line had to be drawn somewhere
	MAX_MESSAGES_PER_SEGMENT = 20
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Message

type Message interface {
	SetCbor([]byte)
	Cbor() []byte
	Type() uint8
}

Provide a common interface for message utility functions

type MessageBase

type MessageBase struct {
	MessageType uint8
	// contains filtered or unexported fields
}

func (*MessageBase) Cbor

func (m *MessageBase) Cbor() []byte

func (*MessageBase) SetCbor

func (m *MessageBase) SetCbor(data []byte)

func (*MessageBase) Type

func (m *MessageBase) Type() uint8

type MessageFromCborFunc

type MessageFromCborFunc func(uint, []byte) (Message, error)

type MessageHandlerFunc

type MessageHandlerFunc func(Message, bool) error

type Protocol

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

func New

func New(config ProtocolConfig) *Protocol

func (*Protocol) Mode added in v0.9.0

func (p *Protocol) Mode() ProtocolMode

func (*Protocol) Role added in v0.9.0

func (p *Protocol) Role() ProtocolRole

func (*Protocol) SendError added in v0.7.0

func (p *Protocol) SendError(err error)

func (*Protocol) SendMessage

func (p *Protocol) SendMessage(msg Message) error

func (*Protocol) Start added in v0.14.0

func (p *Protocol) Start()

type ProtocolConfig added in v0.8.0

type ProtocolConfig struct {
	Name                string
	ProtocolId          uint16
	ErrorChan           chan error
	Muxer               *muxer.Muxer
	Mode                ProtocolMode
	Role                ProtocolRole
	MessageHandlerFunc  MessageHandlerFunc
	MessageFromCborFunc MessageFromCborFunc
	StateMap            StateMap
	InitialState        State
}

type ProtocolMode added in v0.9.0

type ProtocolMode uint
const (
	ProtocolModeNone         ProtocolMode = 0
	ProtocolModeNodeToClient ProtocolMode = 1
	ProtocolModeNodeToNode   ProtocolMode = 2
)

type ProtocolOptions added in v0.9.0

type ProtocolOptions struct {
	Muxer     *muxer.Muxer
	ErrorChan chan error
	Mode      ProtocolMode
	Role      ProtocolRole
	Version   uint16
}

Common arguments for individual mini-protocols

type ProtocolRole added in v0.9.0

type ProtocolRole uint
const (
	ProtocolRoleNone   ProtocolRole = 0
	ProtocolRoleClient ProtocolRole = 1
	ProtocolRoleServer ProtocolRole = 2
)

type State added in v0.5.1

type State struct {
	Id   uint
	Name string
}

func NewState added in v0.5.1

func NewState(id uint, name string) State

func (State) String added in v0.5.1

func (s State) String() string

type StateMap added in v0.8.0

type StateMap map[State]StateMapEntry

type StateMapEntry added in v0.8.0

type StateMapEntry struct {
	Agency      uint
	Transitions []StateTransition
}

type StateTransition added in v0.8.0

type StateTransition struct {
	MsgType   uint8
	NewState  State
	MatchFunc StateTransitionMatchFunc
}

type StateTransitionMatchFunc added in v0.12.0

type StateTransitionMatchFunc func(Message) bool

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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