codec

package
v1.1.2 Latest Latest
Warning

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

Go to latest
Published: Apr 20, 2021 License: BSD-3-Clause Imports: 11 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 MaxAllowedServerCodecPayloadSize = 8 * 1024 * 1024 // 最大包体大小(8M)
View Source
var MaxAllowedSimpleCodecPayloadSize = 8 * 1024 * 1024 // 最大包体大小(8M)
View Source
var ServerProtocolCodec = NewServerProtocolCodec()

Functions

func CompressBytes

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

压缩内容

func DecodePacket added in v1.0.5

func DecodePacket(pkt *fatchoy.Packet, decrypt cipher.BlockCryptor) error

根据pkt的Flag标志位,对body进行解密和解压缩

func EncodePacket added in v1.0.5

func EncodePacket(pkt *fatchoy.Packet, threshold int, encrypt cipher.BlockCryptor) error

根据pkt的Flag标志位,对body进行压缩和加密

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