64 lines
2.6 KiB
Go
64 lines
2.6 KiB
Go
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-8)
|
||
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-8)
|
||
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-8)
|
||
Content string `json:"content"` // 消息内容
|
||
SendTime string `json:"send_time"` // 发送时间
|
||
|
||
// 通话专用字段
|
||
CallID string `json:"call_id,omitempty"` // 通话唯一ID
|
||
CallStatus string `json:"call_status,omitempty"` // 通话状态:invite/accepted/rejected/ended/candidate
|
||
}
|
||
|
||
// 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
|
||
}
|
||
|
||
// 通话信令结构
|
||
type CallSignal struct {
|
||
Action string `json:"action"` // 动作: invite/accept/reject/end/candidate
|
||
CallType int `json:"call_type"` // 通话类型:6=视频,7=语音
|
||
CallID string `json:"call_id"` // 通话唯一ID
|
||
CallerID string `json:"caller_id"` // 主叫用户ID
|
||
CalleeID string `json:"callee_id"` // 被叫用户ID
|
||
Data string `json:"data"` // 数据(SDP/ICE候选)
|
||
}
|
||
|
||
// Redis键常量
|
||
const (
|
||
ClientUserKey = "client_user_mapping" // clientid -> userid映射
|
||
UserClientKey = "user_client_mapping" // userid -> clientid列表
|
||
)
|