fix: 允许服务端为缺失 sessionId 自动生成会话ID
This commit is contained in:
@@ -9,6 +9,7 @@ import (
|
||||
|
||||
"github.com/gofiber/contrib/v3/websocket"
|
||||
"github.com/gofiber/fiber/v3"
|
||||
"github.com/google/uuid"
|
||||
"github.com/vmihailenco/msgpack/v5"
|
||||
)
|
||||
|
||||
@@ -230,7 +231,10 @@ func (h *Handler) handleTextMessage(s *session, data []byte) {
|
||||
}
|
||||
|
||||
func (h *Handler) handleStart(s *session, msg ClientMsg) {
|
||||
if msg.SessionID == "" || len(msg.SessionID) > 96 {
|
||||
if msg.SessionID == "" {
|
||||
msg.SessionID = uuid.NewString()
|
||||
}
|
||||
if len(msg.SessionID) > 96 {
|
||||
h.sendError(s, "invalid_session", "invalid sessionId", false, "")
|
||||
return
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user