codec

package
v0.2.4 Latest Latest
Warning

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

Go to latest
Published: Apr 21, 2021 License: BSD-3-Clause Imports: 9 Imported by: 0

README

codec

codec是编解码实现

  • 使用固定长度的消息头
  • server和client使用不同的编解码方案

Documentation

Index

Constants

View Source
const (
	ClientCodecVersion    = 2  // 协议版本
	ClientCodecHeaderSize = 16 // 消息头大小
)
View Source
const (
	ServerCodecVersion    = 2  // 协议版本
	ServerCodecHeaderSize = 18 // 消息头大小
)
View Source
const (
	SimpleCodecHeaderSize = 12 // 消息头大小
)

Variables

View Source
var (
	MaxAllowedV1SendBytes = 60 * 1024 // 最大发送消息大小(60k)
	MaxAllowedV1RecvBytes = 8 * 1024  // 最大接收消息大小(8k)
)
View Source
var ClientProtocolCodec = NewClientProtocolCodec()
View Source
var MaxAllowedSimpleCodecPayloadSize = 8 * 1024 * 1024 // 最大包体大小(8M)
View Source
var MaxAllowedV2CodecPayloadSize = 8 * 1024 * 1024 // 最大包体大小(8M)
View Source
var ServerProtocolCodec = NewServerProtocolCodec()

Functions

func CompressBytes

func CompressBytes(data []byte) ([]byte, error)

压缩内容

func NewClientProtocolCodec

func NewClientProtocolCodec() fatchoy.ProtocolCodec

func NewServerProtocolCodec

func NewServerProtocolCodec() fatchoy.ProtocolCodec

func UncompressBytes

func UncompressBytes(data []byte) ([]byte, error)

解压内容

Types

This section is empty.

Jump to

Keyboard shortcuts

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