]> git.cworth.org Git - zombocom-ai/commitdiff
Replay previous images to a client when it first connects
authorCarl Worth <cworth@cworth.org>
Wed, 7 Dec 2022 08:58:06 +0000 (00:58 -0800)
committerCarl Worth <cworth@cworth.org>
Wed, 7 Dec 2022 09:27:42 +0000 (01:27 -0800)
so that the images are just as persistent as the comments

index.js

index 8dadeabec11666785f14926cc567caf15c58033f..0ee5e4359255f4afe794114cd043950d0da2c85e 100644 (file)
--- a/index.js
+++ b/index.js
@@ -48,10 +48,13 @@ app.get('/index.html', (req, res) => {
 
 io.on('connection', (socket) => {
 
-    // Replay old comments to a newly-joining client
+    // Replay old comments and images to a newly-joining client
     state.comments.forEach((comment) => {
         socket.emit('comment', comment)
     });
+    state.images.forEach((image) => {
+        socket.emit('image', image)
+    });
 
     // When any client comments, send that to all clients (including sender)
     socket.on('comment', (comment) => {