wsmessage

package
v1.0.2-0...-2da3d3e Latest Latest
Warning

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

Go to latest
Published: Apr 16, 2020 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MessageTypeRoomJoin  string = "ws_room_join"
	MessageTypeRoomLeave string = "ws_room_leave"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type ByteSerializer

type ByteSerializer struct{}

func (ByteSerializer) Deserialize

func (s ByteSerializer) Deserialize(data []byte) (msg Message, err error)

func (ByteSerializer) Serialize

func (s ByteSerializer) Serialize(m Message) ([]byte, error)

type Deserializer

type Deserializer interface {
	Deserialize([]byte) (Message, error)
}

type Message

type Message struct {
	// Types 0-10 are reserved for base functionality, others can be used for
	// custom implementations.
	Type string `json:"type"`
	// Room this message is related to
	Room string `json:"room"`
	// Payload content
	Payload interface{} `json:"payload"`
}

Simple message is a container for web-socket messages.

func NewMessage

func NewMessage(typ string, room string, payload interface{}) Message

func NewMessageRoomJoin

func NewMessageRoomJoin(room string, clientID string, metadata string) Message

func NewMessageRoomLeave

func NewMessageRoomLeave(room string, clientID string) Message

type Serializer

type Serializer interface {
	Serialize(message Message) ([]byte, error)
}

Jump to

Keyboard shortcuts

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