beta v0.2 dualcheck

This commit is contained in:
cancerai committed 2026-08-30 21:25:22 +08:00
1 parent c137299016
commit 1ec68bacf5
14 files changed
+1591 -359

No files matched your search

+21 -4
View File
@@ -8,7 +8,8 @@ import "time"
// ── 创建会话 ──
type CreateRequest struct {
Nickname string `json:"nickname" binding:"required,min=1,max=32"`
Nickname string `json:"nickname" binding:"required,min=1"`
BrowserID string `json:"browser_id"`
}
// CreateResponse 创建成功
@@ -23,7 +24,7 @@ type CreateResponse struct {
type SubmitRequest struct {
SessionID string `json:"session_id" binding:"required,min=8,max=64"`
Nickname string `json:"nickname" binding:"required,min=1,max=32"`
Nickname string `json:"nickname" binding:"required,min=1"`
Role string `json:"role" binding:"required,oneof=initiator participant"`
Text string `json:"text" binding:"required"`
}
@@ -38,7 +39,9 @@ type SubmitResponse struct {
// ── 参与者加入 ──
type JoinRequest struct {
Nickname string `json:"nickname" binding:"required,min=1,max=32"`
SessionID string `json:"session_id" binding:"required,min=8,max=64"`
Nickname string `json:"nickname" binding:"required,min=1"`
BrowserID string `json:"browser_id"`
}
// JoinResponse 返回当前会话全量状态,供参与者初始化 UI
@@ -50,12 +53,18 @@ type JoinResponse struct {
// ── 会话全量状态(发起方拉取 / 发起方 WS 初始化) ──
// SessionRequest 统一的 session_id 请求体
type SessionRequest struct {
SessionID string `json:"session_id" binding:"required,min=8,max=64"`
}
// SessionResponse 发起方看到的会话状态(完整参与者列表)
type SessionResponse struct {
SessionID string `json:"session_id"`
InitiatorNickname string `json:"initiator_nickname"`
InitiatorReady bool `json:"initiator_ready"`
AllowResubmit bool `json:"allow_resubmit"`
IgnoreWs bool `json:"ignore_ws"`
Participants []ParticipantResp `json:"participants"`
TTLSeconds int64 `json:"ttl_seconds"`
}
@@ -74,6 +83,7 @@ type CheckResponse struct {
Exists bool `json:"exists"`
InitiatorReady bool `json:"initiator_ready"`
AllowResubmit bool `json:"allow_resubmit"`
IgnoreWs bool `json:"ignore_ws"`
ParticipantCount int `json:"participant_count"`
TTLSeconds int64 `json:"ttl_seconds"`
}
@@ -82,5 +92,12 @@ type CheckResponse struct {
// SetResubmitRequest 发起方切换"允许参与者重新提交"开关
type SetResubmitRequest struct {
Allow bool `json:"allow"`
SessionID string `json:"session_id" binding:"required,min=8,max=64"`
Allow bool `json:"allow"`
}
// SetIgnoreWsRequest 发起方切换"忽略首尾空白"开关
type SetIgnoreWsRequest struct {
SessionID string `json:"session_id" binding:"required,min=8,max=64"`
Ignore bool `json:"ignore"`
}