]> git.cworth.org Git - zombocom-ai/commitdiff
Tell server a name at first connection
authorCarl Worth <cworth@cworth.org>
Fri, 9 Dec 2022 15:10:32 +0000 (07:10 -0800)
committerCarl Worth <cworth@cworth.org>
Fri, 9 Dec 2022 17:57:24 +0000 (09:57 -0800)
If there is a name in local storage, that is.

index.html

index c556792845e29f6cb668de5c176320516ba3180c..243e1da301e56737691f23f760d5eca84056129b 100644 (file)
@@ -156,6 +156,14 @@ mute.addEventListener("click", () => {
 
     socket.on('reset', () => {
         images.replaceChildren();
+
+        /* Since the server is seeing us for the first time, let it
+           know our name (if we have one). */
+        const name = localStorage.getItem('name');
+        if (name) {
+            socket.emit('set-name', name);
+            return;
+        }
     });
 
     socket.on('image', (image) => {