JsChat: Introduction
JsChat is a protocol for real-time chat based on JSON. This makes it easy to build servers, clients, bots, and web-native applications.
The protocol is currently evolving: JsChat is implemented as a proof of concept as both a web and console client.
Server
The server is written with Ruby and includes unit tests.
Console Client
The console client is meant to be similar to irssi. Typing /help will show available commands. It uses Ncurses and is written with Ruby.
Web Client
The web client must be run alongside a server. The design principles are:
- Simple interface
- Dynamic features: tab complete, URL autolinking, image URLs display inline, YouTube video URLs automatically display as embedded videos
- Portability: only simple Ajax calls are relied on so it will run on most platforms and browsers (iPhone, etc)
Protocol Design
JsChat messages are treated like tuples: a command is provided with one or more pieces of relevant data. The command points to the payload of the message, and other items can be included to aid clients.
- Current commands are: display, change
- Messages take this format: { ‘display’ => ‘message’, ‘message’ => { ‘to’ => ‘#room’, ‘message’ => ‘This is a message’ }
- Time stamps can be included in messages to aid clients
This syntax makes it easy to create classes that interpret the protocol. Consider how simple this would be in JavaScript:
Display = { message: function(message) { ... } } Display[json['display']]
Code
Get the code from my GitHub repository.
Next
Over the next few week, I’ll post here with tutorials and tips on how to install JsChat and manage the server-side daemons. It’s running on jschat.org with Ruby 1.8, Apache and mod_proxy.