message

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: May 12, 2024 License: MPL-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// MaxSize is the maximum supported WebSocket message size.
	MaxSize = 65536
)

Variables

This section is empty.

Functions

func Marshal

func Marshal(msg Message) ([]byte, error)

Marshal marshals a message, returning the data.

func RegisterType

func RegisterType(newMessageOfType func() Message)

RegisterType registers a known message type.

func Type

func Type(msg Message) string

Type returns the string formatted type of the message.

Types

type Message

type Message interface {
	GetAPIVersion() string
	GetKind() string
	GetID() string
	SetID(id string)
}

Message is a message that can be sent/received.

func Unmarshal

func Unmarshal(data []byte) (Message, error)

Unmarshal unmarshals a message from the given data.

type Meta

type Meta struct {
	// APIVersion is the version of the API.
	APIVersion string `json:"apiVersion" mapstructure:"apiVersion"`
	// Kind is the kind of the message.
	Kind string `json:"kind" mapstructure:"kind"`
	// ID is the globally unique message ID, or in the case of an Ack, the ID of
	// the message being acknowledged.
	ID string `json:"id" mapstructure:"id"`
}

func (*Meta) GetID

func (m *Meta) GetID() string

func (*Meta) SetID

func (m *Meta) SetID(id string)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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