proto.go 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. package main
  2. const (
  3. OP_HANDSHARE = int32(0)
  4. OP_HANDSHARE_REPLY = int32(1)
  5. OP_HEARTBEAT = int32(2)
  6. OP_HEARTBEAT_REPLY = int32(3)
  7. OP_SEND_SMS = int32(4)
  8. OP_SEND_SMS_REPLY = int32(5)
  9. OP_DISCONNECT_REPLY = int32(6)
  10. OP_AUTH = int32(7)
  11. OP_AUTH_REPLY = int32(8)
  12. OP_TEST = int32(254)
  13. OP_TEST_REPLY = int32(255)
  14. )
  15. const (
  16. MaxBodySize = int32(1 << 11)
  17. // size
  18. CmdSize = 4
  19. PackSize = 4
  20. HeaderSize = 2
  21. VerSize = 2
  22. OperationSize = 4
  23. SeqIdSize = 4
  24. HeartbeatSize = 4
  25. RawHeaderSize = PackSize + HeaderSize + VerSize + OperationSize + SeqIdSize
  26. MaxPackSize = MaxBodySize + int32(RawHeaderSize)
  27. // offset
  28. PackOffset = 0
  29. HeaderOffset = PackOffset + PackSize
  30. VerOffset = HeaderOffset + HeaderSize
  31. OperationOffset = VerOffset + VerSize
  32. SeqIdOffset = OperationOffset + OperationSize
  33. HeartbeatOffset = SeqIdOffset + SeqIdSize
  34. OP_RAW = int32(11)
  35. )
  36. const (
  37. ProtoVersion0 = iota
  38. ProtoVersion1
  39. ProtoVersion2
  40. ProtoVersion3
  41. )
  42. type Proto struct {
  43. PacketLength int32
  44. HeaderLength int16
  45. Version int16
  46. Operation int32
  47. SequenceId int32
  48. Body []byte
  49. BodyMuti [][]byte
  50. }
  51. type AuthRespParam struct {
  52. Code int64 `json:"code,omitempty"`
  53. }