Documentation ¶
Overview ¶
Package msg contains all message types, as well as serialising and deserialising logic used in peer communications.
Index ¶
- func Encode(msg Msg, w io.Writer) (err error)
- func RegisterDecoder(t Type, decoder func(io.Reader) (Msg, error))
- func RegisterExternalDecoder(t Type, decoder func(io.Reader) (Msg, error), name string)
- func TestMsg(t *testing.T, msg Msg)
- type Cache
- type Cacher
- type Msg
- type PingMsg
- type PongMsg
- type Predicate
- type ShutdownMsg
- type Type
- type WithAnnex
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RegisterDecoder ¶
RegisterDecoder sets the decoder of messages of Type `t`.
func RegisterExternalDecoder ¶
RegisterExternalDecoder sets the decoder of messages of external type `t`. This is like RegisterDecoder but for message types not part of the Perun wire protocol and thus not known natively. This can be used by users of the framework to create additional message types and send them over the same peer connection. It also comes in handy to register types for testing.
Types ¶
type Cache ¶
type Cache struct {
// contains filtered or unexported fields
}
Cache is a message cache. The default value is a valid empty cache.
func (*Cache) Flush ¶
func (c *Cache) Flush()
Flush empties the message cache and removes all predicates.
func (*Cache) Get ¶
Get retrieves all messages from the cache that match the predicate. They are removed from the Cache.
type Cacher ¶
type Cacher interface { // Cache should enable the caching of messages Cache(context.Context, Predicate) }
A Cacher has the Cache method to enable caching of messages.
type Msg ¶
type Msg interface { // Type returns the message's type. Type() Type // encoding of payload. Type byte should not be encoded. perunio.Encoder }
Msg is the top-level abstraction for all messages sent between perun nodes.
type PingMsg ¶
type PingMsg struct {
// contains filtered or unexported fields
}
PingMsg is a ping request. It contains the time at which it was sent, so that the recipient can also measure the time it took to transmit the ping request.
type PongMsg ¶
type PongMsg struct {
// contains filtered or unexported fields
}
PongMsg is the response to a ping message. It contains the time at which it was sent, so that the recipient knows how long the ping request took to be transmitted, and how quickly the response was sent.
type ShutdownMsg ¶ added in v0.3.0
type ShutdownMsg struct {
Reason string
}
ShutdownMsg is sent when orderly shutting down a connection.
func (*ShutdownMsg) Decode ¶ added in v0.3.0
func (m *ShutdownMsg) Decode(r io.Reader) error
Decode implements msg.Decode.
func (*ShutdownMsg) Encode ¶ added in v0.3.0
func (m *ShutdownMsg) Encode(w io.Writer) error
Encode implements msg.Encode.
func (*ShutdownMsg) Type ¶ added in v0.3.0
func (m *ShutdownMsg) Type() Type
Type implements msg.Type.
type Type ¶
type Type uint8
Type is an enumeration used for (de)serializing messages and identifying a message's Type.
const ( Ping Type = iota Pong Shutdown AuthResponse ChannelProposal ChannelProposalAcc ChannelProposalRej ChannelUpdate ChannelUpdateAcc ChannelUpdateRej ChannelSync LastType // upper bound on the message types of the Perun wire protocol )
Enumeration of message categories known to the Perun framework.