mirror of
https://github.com/legop3/MultiRoombaRover.git
synced 2026-09-16 17:40:46 -04:00
25 lines
463 B
JavaScript
25 lines
463 B
JavaScript
const io = require('../globals/io');
|
|
|
|
const COLORS = {
|
|
info: '#2196f3',
|
|
success: '#4caf50',
|
|
warn: '#f0b651',
|
|
error: '#e53935',
|
|
};
|
|
|
|
function sendAlert({ color, title, message, ts = Date.now() }) {
|
|
const payload = {
|
|
color: color || COLORS.info,
|
|
title,
|
|
message,
|
|
ts,
|
|
};
|
|
io.emit('alert', payload);
|
|
io.emit('alert:new', { id: `${ts}-${Math.random().toString(36).slice(2)}`, ...payload });
|
|
}
|
|
|
|
module.exports = {
|
|
COLORS,
|
|
sendAlert,
|
|
};
|