message

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Feb 11, 2020 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PublicTopic = ""
	InnerTopic  = "inner"
	SysTopic    = "sys"
)

Variables

View Source
var (
	TopicSubscribe    = NewTopic("/sys/subscribe")
	TopicCancel       = NewTopic("/sys/cancel")
	TopicCancelAll    = NewTopic("/sys/cancel_all")
	TopicGetAllTopics = NewTopic("/sys/admin/GetAllTopics")
)
View Source
var (
	ErrNotAllowedTopic = errors.New("this topic is not allowed to subscribe or publish")
)
View Source
var InvalidMessage = errors.New("invalid message")

Functions

func IsInnerTopic

func IsInnerTopic(t Topic) bool

func IsPublicTopic

func IsPublicTopic(t Topic) bool

func IsSysTopic

func IsSysTopic(t Topic) bool

func TypeofTopic

func TypeofTopic(t Topic) string

Types

type Serializer

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

func NewSerializer

func NewSerializer(messagePrefix []byte) *Serializer

func (*Serializer) Deserialize

func (ms *Serializer) Deserialize(t Topic, websocketMessage []byte) (interface{}, error)

deserialize deserializes a custom websocket message from the client such as prefix:topic;0:abc_msg Supported data types are: string, int, bool, bytes and JSON.

func (*Serializer) GetMsgTopic

func (ms *Serializer) GetMsgTopic(websocketMessage []byte) Topic

getWebsocketCustomEvent return empty string when the websocketMessage is native message

func (*Serializer) Serialize

func (ms *Serializer) Serialize(t Topic, data interface{}) ([]byte, error)

websocketMessageSerialize serializes a custom websocket message from websocketServer to be delivered to the client returns the string form of the message Supported data types are: string, int, bool, bytes and JSON.

type Topic

type Topic interface {
	String() string
	FirstFragment() string
	Fragment(int) string
	Since(int) string
	Len() int
}

func NewTopic

func NewTopic(t string) Topic

Jump to

Keyboard shortcuts

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