JsChat Blog

JsChat is chat system based on JSON.

Code: github

Web Site: jschat.org

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, install the following gems:

  • mongo
  • mongo_ext
  • twitter_oauth

Then set up an app on Twitter and add your keys to the config file.  The config file can be in /etc/jschat/config.json, and should look like this:

{
  "port": 6789,
  "ip": "0.0.0.0",
  "logger": logger,
  "max_message_length": 500,
  "tmp_files": "/tmp/file/path",
  "db_name": "jschat",
  "db_host": "localhost",
  "db_port": 27017,
  "db_username": "",
  "db_password": "",
  "twitter" { "key": "xxx", "secret": "xxx" }
}

All of the options are optional, so leave any out that you don’t need.  For example, the one we use on the JsChat server looks like this:

{ 
  "twitter": { "key": "xxx", "secret": "xxx" },
  "db_host": "swan.mongohq.com",
  "db_port": "27080",
  "db_username": "user",
  "db_password": "pass
}