codec

package
v1.1.3 Latest Latest
Warning

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

Go to latest
Published: Jun 30, 2020 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MTU = 1500 // 最大传输单元

)

Variables

This section is empty.

Functions

func ParserPacket

func ParserPacket(data []byte) (int, interface{}, error)

----------------------------------------------【解析包】--------------------------------------------------

func ParserWSPacket

func ParserWSPacket(pkt []byte) (int, interface{}, error)

----------------------------------------------【ws】--------------------------------------------------

func SendPacket

func SendPacket(w io.Writer, msg interface{}) error

----------------------------------------------【发送包】--------------------------------------------------

func SendUdpPacket

func SendUdpPacket(w *net.UDPConn, msg interface{}, toAddr *net.UDPAddr) error

func SendWSPacket

func SendWSPacket(w *websocket.Conn, msg interface{}) error

func SetDefaultCodec

func SetDefaultCodec(codec Codec)

默认编码器

Types

type Codec

type Codec interface {
	Encode(v interface{}) (data []byte, err error)
	Decode(data []byte, vObj interface{}) error
	Type() string
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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