March 2010
3 posts
Twitter Auth, Mongo Logging and Tabs
JsChat now has Twitter Auth, logging with mongodb, and the web interface has tabs for switching between rooms. Twitter auth and mongodb give JsChat persistence.
People can sign in with Twitter, join a set of rooms, then sign in from another computer without appearing to log off JsChat. The user stays online until they’ve been idle for 7 days or they click Quit.
To get these features,...
Protocol Changes
The JsChat Protocol has been changed to include a time parameter in all messages. That means the display style messages no longer contain the time, it’s at the top level instead:
{ 'display' => 'message', 'message' => { ... }, 'time' => 'Tue Mar 30 15:17:02 UTC 2010' }
Gem Released
I’ve bundled JsChat into a gem so you can install it with:
gem install jschat
This makes it possible to run JsChat from the command line:
jschat-server - runs the server
jschat-web - runs a web app
jschat-client - runs the console client
I’ve also added config files. They’re in JSON format, and you need to double quote the keys. The default locations are (client)...
November 2009
2 posts
Stateless Protocol: Complete
JsChat now has a stateless protocol. This means you can register a cookie with the server that will persist a client connection across socket sessions.
The protocol works like this:
Connect to a server and send a JSON string with protocol set to stateless
The server will send back a cookie
On every subsequent request, provide the cookie
Here’s a code example: stateless_example.rb
One...
Stateless Protocol
I’m working on making the JsChat protocol stateless. This means that the web client’s complexity will be greatly reduced in the future.
I’m going to make the stateless mode optional, so clients can connect using sockets or single requests.
June 2009
4 posts
Clojure Bot
Here’s an example of a bot written with Clojure: Clojure JsChat Bot. It might not be 100% idiomatic Clojure, but it shows that talking JsChat is simple in Clojure.
Clojure comes bundled with JSON libraries for creating and parsing JSON. The parser returns a PersistentArrayMap: ((parsed-json "message") "message") accesses the message body element of a JsChat message.
JavaScript Bots
I’ve made an example of a JavaScript bot for JsChat. You can run it using Rhino, and it uses Java’s sockets for connections:
$ rlwrap java -jar js.jar Rhino 1.7 release 2 2009 03 22 js> load('bot.js')
Notice how simple the code for interpreting the protocol is. I’ve used the same strategy as the JsChat client and server code, whereby methods are executed based on the...
Kev and his Emotes
Kev originally wanted us to build JsChat about 3 years ago. We haven’t quite implemented his idea yet (which was about monetizing IRC-style chat), but he’s had a lot of ideas and feature suggestions for JsChat so far. One that he was particularly concerned about was emoticons, so I included them on a rainy Sunday afternoon.
I just updated the web app with a command so you can list...
Passenger/Rack Support
I’ve just checked in Passenger and Rack support with a config.ru sample into the JsChat repo. It should now be easy to get JsChat working with Passenger if you use it on your servers.
I also made message submissions display in realtime in the web app’s chat transcript. This means there’s instant feedback when a message is posted.
May 2009
2 posts
JsChat: Polling
People are repeatedly joining #jschat talking about the merits of polling. Please read this before you do that, or you’re likely to get ignored:
Yes, I know about server-sent events and flash hacks that provide sockets
No, we’re not going to use Juggernaut
JsChat will gradually support native server-sent events (some browsers provide this already)
I used polling because it works...
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...