event

package
v0.0.8 Latest Latest
Warning

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

Go to latest
Published: Jan 18, 2022 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Event

type Event struct {
	Topic     string      `json:"topic,omitempty" msgpack:"topic,omitempty"`
	Sender    string      `json:"sender,omitempty" msgpack:"sender,omitempty"`
	EventTime int64       `json:"event_time,omitempty" msgpack:"event_time,omitempty"` //毫秒级时间戳
	EventID   string      `json:"event_id,omitempty" msgpack:"event_id,omitempty"`
	Payload   interface{} `json:"payload" msgpack:"payload"`
}

Event 消息对象

func DefaultParser

func DefaultParser(SerializeProtocol, topic, eventID, payloadstr string, payload map[string]interface{}) (*Event, error)

DefaultParser 默认的消息处理函数负载会被解析为 m,ap[string]interface{}

type Handdler

type Handdler func(msg *Event) error

Handdler 处理消息的回调函数 @params msg *Event Event对象

type Parser

type Parser func(SerializeProtocol, topic, eventID, payloadstr string, payload map[string]interface{}) (*Event, error)

Parser 用于将负载字符串转化为event的函数 规定eventID不为""时解析流的消息,用到topic, eventID, payload 规定eventID为""时解析除流之外的消息,用到SerializeProtocol,topic, payloadstr

Jump to

Keyboard shortcuts

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