relay.local
Real-Time Chat Application
A WebSocket chat server with a server-rendered Handlebars front end.
- Raw
- WebSockets
- Multi-client
- messaging
Web app screen: Design crit, with Open thread on a phone. 1 of 3
ws.readyState === 1 fires late, so the green dots lag ~400ms. patch in a bit.ws.readyState fires late, so the dots lag ~400ms.Problem
A standalone messaging module built to learn raw WebSocket handling without a framework like Socket.IO.
I wanted the full socket lifecycle in view: connect, broadcast, reconnect, and presence. A wrapper library would have hidden the parts I was trying to learn.
Solution
Built the chat server and front end independently.
- Built a WebSocket-based chat server in Node.js with a Handlebars-rendered front end.
- Used Moment.js to format and display message timestamps.
Mobile surfaces
The Handlebars UI scales down to a phone-width layout. Inbox, rooms, and DMs share one WebSocket connection, so unread counts and typing state stay aligned across views.
- RelaySearch messages, people…AllUnreadRoomsDMsTODAYEARLIERsocket open/14 ms
Phone screen: Conversation list stays in sync with the socket feed
- MOMaya Okonkwosocket open/14 ms8 clientsTodayMOMaya Okonkwo11:41can you sanity-check the reconnect handler before I merge? staging looks fine but I want another pair of eyes on the close code path.You11:43on it. I will run through a tab refresh and a hard network drop.MOMaya Okonkwo11:58ok — patch is up, reconnecting nowMessage Maya
Phone screen: Direct messages on the same WebSocket session
Stack
- Node.js
- WebSockets
- JavaScript
- Handlebars
- Moment.js
Outcomes
- Raw
- WebSockets
- Multi-client
- messaging
- Working real-time messaging between multiple connected clients over raw WebSockets, with no framework abstraction between the socket layer and the app.