Files
nl-im-websocket-demo/models/messages.go
2025-07-03 08:50:38 +08:00

50 lines
1.9 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
package models
// 统一消息结构(发送方使用)
type SendMessagePayload struct {
RequestType string `json:"request_type"` // 消息类型
TargetClientID string `json:"target_client_id"` // 目标客户端ID
SenderUserID string `json:"sender_user_id"` // 发送者用户ID
ReceiverUserID string `json:"receiver_user_id"` // 接收者用户ID
MessageType int `json:"message_type"` // 消息类型0-6
MessageContent string `json:"message_content"` // 消息内容
}
// 通过用户ID发送消息的结构
type SendToUserPayload struct {
SenderUserID string `json:"sender_user_id"` // 发送者用户ID
ReceiverUserID string `json:"receiver_user_id"` // 接收者用户ID
MessageType int `json:"message_type"` // 消息类型0-6
MessageContent string `json:"message_content"` // 消息内容
}
// 客户端接收消息结构(最终格式)
type ClientReceivedMessage struct {
SenderID string `json:"sender_id"` // 发送者连接ID
ReceiverID string `json:"receiver_id"` // 接收者连接ID
SenderUserID string `json:"sender_user_id"` // 发送者用户ID
ReceiverUserID string `json:"receiver_user_id"` // 接收者用户ID
MessageType int `json:"message_type"` // 消息类型0-6
Content string `json:"content"` // 消息内容
SendTime string `json:"send_time"` // 发送时间
}
// Redis 消息结构
type RedisMessage struct {
SenderNodeID string `json:"sender_node_id"` // 发送节点ID
ClientID string `json:"client_id"` // 目标客户端ID
Message string `json:"message"` // 消息内容
}
// 用户绑定请求结构
type BindRequest struct {
UserID string `json:"user_id"` // 用户ID
ClientID string `json:"client_id"` // 客户端ID
}
// Redis键常量
const (
ClientUserKey = "client_user_mapping" // clientid -> userid映射
UserClientKey = "user_client_mapping" // userid -> clientid列表
)