protocol.go 695 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. package liverpc
  2. import "encoding/json"
  3. const (
  4. _magic = 2233
  5. _headerLen = 60
  6. _cmdReqType = byte('0')
  7. )
  8. type protoHeader struct {
  9. magic uint32
  10. timestamp uint32
  11. checkSum uint32
  12. version uint32
  13. reserved uint32
  14. seq uint32
  15. length uint32
  16. cmd []byte
  17. }
  18. type protoReq struct {
  19. Header protoHeader
  20. Body []byte
  21. }
  22. type protoResp struct {
  23. Header protoHeader
  24. Body []byte
  25. }
  26. // Args .
  27. type Args struct {
  28. Header *Header `json:"header"`
  29. Body interface{} `json:"body"`
  30. HTTP interface{} `json:"http"`
  31. }
  32. // Reply .
  33. type Reply struct {
  34. Code int `json:"code"`
  35. Message string `json:"msg"`
  36. Data json.RawMessage `json:"data"`
  37. }