MCPcopy Create free account
hub / github.com/bytemode/pitaya-notes / Encode

Method Encode

conn/codec/pomelo_packet_encoder.go:53–70  ·  view source on GitHub ↗

type(1byte) + length(3byte) + body(length bytes) package分为header和body两部分。header描述package包的类型和包的长度,body则是需要传输的数据内容。 type - package类型,1个byte 0x01: 客户端到服务器的握手请求以及服务器到客户端的握手响应 0x02: 客户端到服务器的握手ack 0x03: 心跳包 0x04: 数据包 0x05: 服务器主动断开连接通知 length - body内容长度,3个byte的大端整数,因此最大的包长度为2^24个byte。 body - 二进制的传输内容

(typ packet.Type, data []byte)

Source from the content-addressed store, hash-verified

source not stored for this graph (policy: none)

Callers 2

TestEncodeFunction · 0.95
TestHandlerServiceHandleFunction · 0.95

Calls 1

intToBytesFunction · 0.85

Tested by 2

TestEncodeFunction · 0.76
TestHandlerServiceHandleFunction · 0.76