fix
All checks were successful
Deploy on Master Change / deploy (push) Successful in 1m38s

This commit is contained in:
2026-07-14 08:02:47 +07:00
parent f4b9d99051
commit a55b0a4567
2 changed files with 5 additions and 2 deletions

View File

@@ -518,8 +518,11 @@ func WebSocketHandler(db *gorm.DB) func(*websocket.Conn) {
ImageBuffer json.RawMessage `json:"imageBuffer"` ImageBuffer json.RawMessage `json:"imageBuffer"`
} `json:"data"` } `json:"data"`
} }
if err := json.Unmarshal(msgBytes, &frameMsg); err == nil { if err := json.Unmarshal(msgBytes, &frameMsg); err == nil && len(frameMsg.Data.ImageBuffer) > 0 {
Hub.RelayFrameRaw(client.StudentID, eventMsg.Event, frameMsg.Data.ImageBuffer) // Copy slice to avoid memory race / corruption since WebSocket read buffer gets recycled
bufCopy := make([]byte, len(frameMsg.Data.ImageBuffer))
copy(bufCopy, frameMsg.Data.ImageBuffer)
Hub.RelayFrameRaw(client.StudentID, eventMsg.Event, json.RawMessage(bufCopy))
} }
continue continue
} }

Binary file not shown.