WebSocket protocol
Your server should accept JSON messages. The browser sends:
{"type":"join","room":"general","name":"Alex","clientId":"..."}
{"type":"message","room":"general","name":"Alex","text":"Hello","clientId":"...","id":"...","time":123}
{"type":"typing","room":"general","name":"Alex","active":true,"clientId":"..."}
The page accepts those same message types, plus:
{"type":"presence","room":"general","users":["Alex","Sam"]}
Hosting note
A static HTML file cannot itself host a shared database or WebSocket service. Serve this file over HTTPS and point it at a wss:// endpoint. A reverse proxy can expose your socket at /ws on the same domain.