June 2024
Beginner to intermediate
268 pages
6h 26m
English
Instead of sending messages as unadorned strings, as we did in the last chapter, let’s use JSON to structure some metadata with each message sent over the chat. To start with, the remote peer will use the metadata’s content to acknowledge each message received. We can even add a little CSS so that, on the sender’s side, there is a visual difference between messages that have been received by the remote peer and those that have not.
Sending JSON isn’t much different from sending strings: JSON, or JavaScript Object Notation, is a fancy kind of string. Let’s rework handleMessageForm() so that it builds a small object literal on message in place of the message strings we relied on in the ...
Read now
Unlock full access