refactor: enhance player update handling to include label and timestamp for improved tracking
This commit is contained in:
@@ -329,7 +329,10 @@ wss.on('connection', (ws, req) => {
|
|||||||
db.savePlayerPosition(data.playerID, data.position);
|
db.savePlayerPosition(data.playerID, data.position);
|
||||||
broadcastToClients({
|
broadcastToClients({
|
||||||
type: 'player_update',
|
type: 'player_update',
|
||||||
player: { id: data.playerID, ...data.position },
|
playerID: data.playerID,
|
||||||
|
position: data.position,
|
||||||
|
label: data.label || null,
|
||||||
|
timestamp: Date.now(),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1508,7 +1511,7 @@ app.post('/api/groups/:groupId/command', (req, res) => {
|
|||||||
// Player position endpoints
|
// Player position endpoints
|
||||||
app.post('/api/player/update', (req, res) => {
|
app.post('/api/player/update', (req, res) => {
|
||||||
try {
|
try {
|
||||||
const { playerID, position, timestamp } = req.body;
|
const { playerID, position, timestamp, label } = req.body;
|
||||||
|
|
||||||
if (!playerID || !position) {
|
if (!playerID || !position) {
|
||||||
return res.status(400).json({ error: 'Missing playerID or position' });
|
return res.status(400).json({ error: 'Missing playerID or position' });
|
||||||
@@ -1521,6 +1524,7 @@ app.post('/api/player/update', (req, res) => {
|
|||||||
type: 'player_update',
|
type: 'player_update',
|
||||||
playerID,
|
playerID,
|
||||||
position,
|
position,
|
||||||
|
label: label || null,
|
||||||
timestamp: timestamp || Date.now()
|
timestamp: timestamp || Date.now()
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user