What is it?
This is a weekend project online chat app based on WebSockets written in Go. Frontend is built with pure HTML, JS, and TailwindCSS. Messages only last for the duration of the session and are not saved anywhere other than the HTML displayed. Any number of users can join the chat, and they can all pick usernames.
How does it work?
Server serves a home page (server-side rendered html/js/css) and accepts socket connections. Whenever a client connects, a goroutine is launched that accepts JSON payloads from that client forever, and feeds them into a channel.
The frontend responds to server messages (ex. message broadcast, user listing). The server saves all socket connections (and their corresponding usernames, TODO: fix bug for duplicate usernames) and uses them to broadcast new users and messages.