Improve chat example JavaScript code.

Resolves #2617.
This commit is contained in:
Sergio Benitez 2023-09-20 13:55:59 -07:00
parent 26a3f00f82
commit 498af3d9d0
1 changed files with 1 additions and 1 deletions

View File

@ -94,7 +94,7 @@ function subscribe(uri) {
console.log("raw data", JSON.stringify(ev.data));
console.log("decoded data", JSON.stringify(JSON.parse(ev.data)));
const msg = JSON.parse(ev.data);
if (!"message" in msg || !"room" in msg || !"username" in msg) return;
if (!("message" in msg) || !("room" in msg) || !("username" in msg)) return;
addMessage(msg.room, msg.username, msg.message, true);
});