protocol

package
v1.19.1 Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2022 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	//BKDataPlugin 数据转给蓝鲸
	BKDataPlugin = 0x01

	// HeartBeatDetect 心跳包
	HeartBeatDetect = 0x02

	// 数据传给defaultExporter
	DefaultExporterPlugin = 0x03
)
View Source
const ProtocolMagicNum uint64 = 0x75062D90E03C798A

ProtocolMagicNum 防篡改魔法数字

Variables

This section is empty.

Functions

func CreateProtocolBuffer

func CreateProtocolBuffer(handler HandlerIf) io.Writer

CreateProtocolBuffer 创建protocolBuffer用于接收数据, handler 接收业务数据的接口

func HeadLength

func HeadLength() int

HeadLength 获取协议头长度

func Package

func Package(msgHead *MsgHead, data []byte) ([]byte, error)

Package 打包数据

Types

type HandlerIf

type HandlerIf interface {

	// Write 转发接收到的数据和协议头数据给逻辑层
	Write(head *MsgHead, data []byte) (int, error)
}

HandlerIf 用于接收服务端收到的数据

type MsgHead

type MsgHead struct {
	Magic     uint64
	Type      uint32
	Length    uint32
	ExtID     int64
	Timestamp int64
}

MsgHead 通讯协议头协议头定义

func ConvertToMsgHead

func ConvertToMsgHead(buffer []byte) (*MsgHead, error)

ConvertToMsgHead 将字节数组 转换为协议头

Jump to

Keyboard shortcuts

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