engine

package
v0.0.0-...-3b464d1 Latest Latest
Warning

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

Go to latest
Published: Jun 23, 2017 License: BSD-3-Clause Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// MsgTypeReserved : Reserved
	MsgTypeReserved byte = iota
	// MsgTypeOnline : Online message
	MsgTypeOnline
	// MsgTypeOnlineAck : Online ACK
	MsgTypeOnlineAck
	// MsgTypeOffline : Offline message
	MsgTypeOffline
	// MsgTypeOfflineAck : Offline ACK
	MsgTypeOfflineAck
	// MsgTypeUpward : Upward message
	MsgTypeUpward
	// MsgTypeUpwardAck : Upward ACK
	MsgTypeUpwardAck
	// MsgTypeDownward : Downward message
	MsgTypeDownward
	// MsgTypeDownwardAck : Downward ACK
	MsgTypeDownwardAck
	// MsgTypePing : Heartbeat PING
	MsgTypePing
	// MsgTypePong : Heartbeat PONE
	MsgTypePong
)
View Source
const (
	// MsgStageHeader : Header needed (Type + CompressMode + SerializeMode) + (BodyLength) (5 bytes)
	MsgStageHeader byte = iota
	// MsgStageBody : Body needed (n bytes)
	MsgStageBody
	// MsgStageComplete : All done
	MsgStageComplete
)

const (

// MsgStageHeader : Header needed (Type + CompressMode + SerializeMode) (1 byte)
MsgStageHeader int = iota
// MsgStageUids : Uids needed (2 bytes)
MsgStageUids
// MsgStageUID : UID array needed ((8 * Uids) bytes)
MsgStageUID
// MsgStageLength : Payload length needed (4 bytes)
MsgStageLength
// MsgStagePayload : Payload data needed (length bytes)
MsgStagePayload
// MsgStageComplete : All done
MsgStageComplete

)

View Source
const (
	// MsgCompressNone : No compression
	MsgCompressNone byte = iota
	// MsgCompressDeflate : Deflate (GNU zip)
	MsgCompressDeflate
	// MsgCompressSnappy : Google snappy
	MsgCompressSnappy
	// MsgCompressLZ4 : LZ4
	MsgCompressLZ4
)
View Source
const (
	// MsgSerializeRaw : No serialization
	MsgSerializeRaw byte = iota
	// MsgSerializeJSON : JSON
	MsgSerializeJSON
	// MsgSerializeMsgPack : MessagePack
	MsgSerializeMsgPack
	// MsgSerializeAMF3 : AMF3
	MsgSerializeAMF3
)

Variables

This section is empty.

Functions

func Command

func Command(data Message)

Command : Input command data

{{{ [Command]

func Start

func Start(logger *log.Logger)

Start :Slater engine startup

{{{ [Start]

Types

type Body

type Body struct {
	App     string
	UID     []int64
	Payload []byte
}

Body : Message body

func NewBody

func NewBody() (body *Body)

NewBody : Create a new body

{{{ [NewBody]

type CommonCommand

type CommonCommand struct {
	Additional map[string]string      `cmd:"Additional"`
	Command    int                    `cmd:"Command"`
	Params     map[string]interface{} `cmd:"Params"`
}

CommonCommand : Common command

func CmdDecode

func CmdDecode(raw []byte, t byte) (*CommonCommand, error)

CmdDecode : Decode bytes into struct

{{{ [CmdDecode]

func (*CommonCommand) Encode

func (cmd *CommonCommand) Encode(t byte) ([]byte, error)

Encode : Encode command struct into bytes

{{{ [Encode] Encode command

func (*CommonCommand) ToRaw

func (cmd *CommonCommand) ToRaw() []byte

ToRaw : CommonCommand to raw byte array

type Message

type Message struct {
	Type          byte
	SerializeMode byte
	CompressMode  byte
	BodyLength    uint32
	Body          Body

	Stage byte
	// contains filtered or unexported fields
}

Message : Data struct defination

func NewMessage

func NewMessage(buf *bytes.Buffer) (msg *Message)

NewMessage : Create a new message

{{{ [NewMessage]

func (*Message) Parse

func (msg *Message) Parse() (bool, error)

Parse : Try parse

{{{ [Parse] Try parse message

func (*Message) Stream

func (msg *Message) Stream() ([]byte, error)

Stream : Build bytes

{{{ [Stream] Serialize message to bytes

Jump to

Keyboard shortcuts

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