package message import ( "encoding/json" ) // 事件 type EventMessage struct { Message Tag EventTag // 消息标签:EventTagUser=用户 Flag EventFlag // 消息标签:EventFlagCreate=创建 EventFlagUpdate=更新 EventFlagSave=创建或更新 EventFlagDelete=删除 EventId string // 事件ID EventContent any // 事件内容 } type EventTag string const ( EventTagUser = "user" EventTagRoomInto EventTag = "into_room" ) type EventFlag string const ( EventFlagSave EventFlag = "save" EventFlagCreate EventFlag = "create" EventFlagUpdate EventFlag = "update" EventFlagDelete EventFlag = "delete" ) func (message *EventMessage) ToJson() string { b, _ := json.Marshal(message) return string(b) }