codec

package
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Feb 25, 2021 License: BSD-3-Clause Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ClientCodecVersion    = 1         // 协议版本
	ClientCodecHeaderSize = 14        // 消息头大小
	MaxAllowedV1SendBytes = 60 * 1024 // 最大发送消息大小(60k)
	MaxAllowedV1RecvBytes = 16 * 1024 // 最大接收消息大小(16k)
)
View Source
const (
	ZLIB  CompressType = 1
	FLATE CompressType = 2
	GZIP  CompressType = 3

	DefaultCompression = 0
	BestSpeed          = 1
	BestCompression    = 2
)
View Source
const (
	ServerCodecVersion      = 1               // 协议版本
	ServerCodecHeaderSize   = 24              // 消息头大小
	MaxAllowedV2PayloadSize = 8 * 1024 * 1024 // 最大包体大小(8M)
)

Variables

View Source
var ErrUnsupportedCodec = errors.New("unsupported codec type")

Functions

func CompressBytes

func CompressBytes(ctype CompressType, level int, data []byte) ([]byte, error)

func NewClientCodec added in v1.0.2

func NewClientCodec() *clientCodec

func NewServerCodec added in v1.0.2

func NewServerCodec() *serverCodec

func UnCompressBytes added in v1.0.2

func UnCompressBytes(ctype CompressType, data []byte) ([]byte, error)

Types

type CompressType added in v1.0.2

type CompressType int

Jump to

Keyboard shortcuts

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