This commit is contained in:
@@ -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.
Reference in New Issue
Block a user