message.go 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. package types
  2. import "time"
  3. type FrameType uint8
  4. const (
  5. FrameData FrameType = 0x0
  6. FramePing FrameType = 0x1
  7. FrameErr FrameType = 0x9
  8. FrameAck FrameType = 0x2
  9. FrameNoAck FrameType = 0x3
  10. )
  11. type (
  12. Msg struct {
  13. MType `mapstructure:"mType"`
  14. Content string `mapstructure:"content"` //内容
  15. MsgID string `mapstructure:"msgId"` // 消息id
  16. ReadRecords map[string]string `mapstructure:"readRecords"` // 阅读消息记录
  17. }
  18. Chat struct {
  19. ConversationId string `mapstructure:"conversationId"` // 会话id
  20. ChatType `mapstructure:"chatType"` // 会话类型
  21. SendID int64 `mapstructure:"sendId"` //发送者
  22. RecvID int64 `mapstructure:"recvId"` //接收者
  23. Msg `mapstructure:"msg"` // 消息接口
  24. SendTime int64 `mapstructure:"sendTime"` // 消息发送时间
  25. }
  26. Push struct {
  27. ConversationId string `mapstructure:"conversationId"` // 会话id
  28. ChatType `mapstructure:"chatType"` // 会话类型
  29. SendID int64 `mapstructure:"sendId"` //发送者
  30. RecvID int64 `mapstructure:"recvId"` //接收者
  31. RecvIDs []int64 `mapstructure:"recvIds"` //多个接收者
  32. SendTime int64 `mapstructure:"sendTime"` //消息发送时间
  33. MsgID string `mapstructure:"msgId"` // 消息id
  34. ReadRecords map[string]string `mapstructure:"readRecords"` //消息阅读记录
  35. ContentType ContentType `mapstructure:"contentType"` // 消息内容类型
  36. MType `mapstructure:"mType"`
  37. Content string `mapstructure:"content"` // 消息内容
  38. ID string `json:"id"` // 消息id
  39. }
  40. MarkRead struct {
  41. ChatType `mapstructure:"chatType"`
  42. RecvID int64 `mapstructure:"recvId"` //接收者
  43. ConversationId string `mapstructure:"conversationId"`
  44. MsgIds []string `mapstructure:"msgIds"`
  45. }
  46. MessagePushData struct {
  47. FrameType `json:"frame_type"` //消息类型
  48. Id string `json:"id"`
  49. AckSeq int `json:"ack_seq"` // ack seq
  50. AckTime time.Time `json:"ackTime"` // ack时间
  51. AccErrCount int `json:"errCount"` // ack失败次数
  52. Method string `json:"method,omitempty"` // 消息处理方法
  53. FormID int64 `json:"form_id,omitempty"` // 接收者id
  54. UserID int64 `json:"user_id,omitempty"` // 发送者id
  55. Data interface{} `json:"data,omitempty"` // 消息内容
  56. }
  57. )