# TCP推送协议

基于TCP Socket长链接。

报文格式:通讯头(header) + 报文体(msgBody)+业务实体(payload)。

header固定151字节。

msgBody采用Protobuf编码二进制格式。推送(PBNotify)payload为业务实体,见具体接口中“消息类型”定义部分。

# 通讯头

位数 属性 类型 说明 可能值 默认值
1-2 szHeaderFlag Chars(utf-8) 包头起始标志 固定为"HS" HS
3-4 msgType Int16(Little Endian) 消息类型 OpenAPI Gateway 仅使用 "3" 推送 3
5 protoFmtType Byte 数据格式 OpenAPI Gateway 仅使用 "0" Protobuf 0
6 protoVer Byte 协议版本,用于迭代兼容 0
7-10 serialNo Int32(Little Endian) 包序列号,要求递增
11-14 bodyLen Int32(Little Endian) 包体最终(加密后)长度 OpenAPI Gateway 为解密后长度
15-142 bodySHA1 Bytes 包体原始数据的SHA1WithRSA签名值,用于验签 OpenAPI Gateway 已自动签名(日志)
143 compressAlgorithm Byte 压缩算法 OpenAPI Gateway 仅使用 "0"不压缩 0
144-151 reserved Int64(Little Endian) 保留8字节扩展

# 推送报文体

message PBNotify {
    NotifyMsgType notifyMsgType = 1;
    string notifyId = 2;
    uint64 notifyTime = 3;
    google.protobuf.Any payload = 4; 
}
属性 类型 说明
notifyMsgType NotifyMsgType枚举 推送消息类型
notifyId String 推送ID
notifyTime Long 推送时间戳
payload Any 推送消息实体