package protocol // protocol // 1byte: magic: 99 // 1byte: 1 request, 2 response, 3 event, 4 error // 1byte: status: 20-OK, 30-CLIENT_TIMEOUT, 31-SERVER_TIMEOUT, 40-BAD_REQUEST, 41-BAD_RESPONSE, 44-SERVICE_NOT_FOUND, 50-CLIENT_ERROR, 51-SERVER_ERROR, 52-SERVICE_ERROR // 4bit: svc,method url desc: 1 name, 2 number // 4bit: serialize: 1proto, 2json // 4byte: seqId // string: service, method / 4byte svc, 4byte method/4byte notice // proto bytes / json bytes const ( Magic int8 = 99 TypeRequest int8 = 1 TypeResponse int8 = 2 TypeNotice int8 = 3 TypeError int8 = 4 ) type Header struct { Magic int8 Type int8 // 1 request, 2 response, 3 event, 4 error Status int8 UrlType int8 SerializeType int8 SeqId int32 SvcNo int32 MethodNo int32 Svc string Method string } type Payload struct { Header Header Body []byte }