// When any client comments, send that to all clients (including sender)
socket.on('comment', (comment) => {
+ comment.name = socket.request.session.name;
io.emit('comment', comment);
state.comments.push(comment);
});
child.stdout.on('data', (data) => {
const images = JSON.parse(data);
images.forEach((image) => {
- console.log(`Emitting image to clients: ${image}`);
+ image.index = state.images.length;
io.emit('image', image);
state.images.push(image);
});