fsb_backbone/server/selectionStateChange.js
Martin Donnelly e1d9657e87 init
2021-03-12 07:55:43 +00:00

26 lines
703 B
JavaScript

module.exports = (data, socket) => {
const selections = [];
data.category.forEach(category => {
category.subcat.forEach(subcat => {
subcat.event.forEach(event => {
event.selection.forEach(selection => {
const { id, price } = selection;
selections.push({
active: Math.random() >= 0.5,
price,
id
});
});
});
});
});
selections.forEach(selection =>
setTimeout(() => { socket.emit('selectionStateUpdate', selection) }, 1000 * (Math.floor(Math.random() * 25) + 1))
);
};