fixedlen

package
v0.0.0-...-3153823 Latest Latest
Warning

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

Go to latest
Published: Nov 30, 2020 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package fixedlen : header + payload header: '负载长度(U16)' + '标记(U16)' + '自增编号(U16)' + '消息编号(U16)' payload: 负载,即消息内容,使用 codec 进行编码与解码 对于标记见 flag.go

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrGetPayloadLen 获取负载长度失败
	ErrGetPayloadLen = errors.New("get payload length failed")

	// ErrGetFlag 获取标记失败
	ErrGetFlag = errors.New("get flag failed")

	// ErrGetSN 获取自增编号失败
	ErrGetSN = errors.New("get sn failed")

	// ErrGetMessageID 获取消息编号失败
	ErrGetMessageID = errors.New("get message id failed")

	// ErrGetPayload 获取负载失败
	ErrGetPayload = errors.New("get payload failed")
)

Functions

func NewFixedLen

func NewFixedLen(opts ...Option) network.Datapack

NewFixedLen ..

func NewMessageFromClient

func NewMessageFromClient(id network.MessageID, flag, sn uint16, payload []byte) network.Message

NewMessageFromClient ..

func NewMessageFromServer

func NewMessageFromServer(id network.MessageID, flag, code uint16, payload []byte) network.Message

NewMessageFromServer ..

Types

type Config

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

Config 一些配置

type Option

type Option func(*fixedLen)

Option ..

func WithCompress

func WithCompress(compress compress.Compress) Option

WithCompress 设置压缩与解压器

func WithCompressThreshold

func WithCompressThreshold(threshold uint32) Option

WithCompressThreshold 加密的阈值,当消息负载长度超过该值时才会加密

func WithOrder

func WithOrder(order binary.ByteOrder) Option

WithOrder 设置字节流大端还是小端

func WithWhetherCompress

func WithWhetherCompress(isCompress bool) Option

WithWhetherCompress 是否需要对消息负载进行加密

func WithWhetherCrypto

func WithWhetherCrypto(isCrypto bool) Option

WithWhetherCrypto 是否需要对消息负载进行加密

Jump to

Keyboard shortcuts

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