<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:dc="http://purl.org/dc/elements/1.1/" version="2.0"><channel><atom:link rel="hub" href="http://tumblr.superfeedr.com/" xmlns:atom="http://www.w3.org/2005/Atom"/><description>JsChat is chat system based on JSON.

Code: github

Web Site: jschat.org</description><title>JsChat Blog</title><generator>Tumblr (3.0; @jschat)</generator><link>http://blog.jschat.org/</link><item><title>Twitter Auth, Mongo Logging and Tabs</title><description>&lt;p&gt;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.&lt;/p&gt;
&lt;p&gt;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&amp;#8217;ve been idle for 7 days or they click Quit.&lt;/p&gt;
&lt;p&gt;To get these features, install the following gems:&lt;/p&gt;
&lt;ul&gt;&lt;li&gt;mongo&lt;/li&gt;
&lt;li&gt;mongo_ext&lt;/li&gt;
&lt;li&gt;twitter_oauth&lt;/li&gt;
&lt;/ul&gt;&lt;p&gt;Then &lt;a href="http://twitter.com/apps"&gt;set up an app&lt;/a&gt; on Twitter and add your keys to the config file.  The config file can be in &lt;code&gt;/etc/jschat/config.json&lt;/code&gt;, and should look like this:&lt;/p&gt;
&lt;pre&gt;{
  "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" }
}
&lt;/pre&gt;
&lt;p&gt;All of the options are optional, so leave any out that you don&amp;#8217;t need.  For example, the one we use on the JsChat server looks like this:&lt;/p&gt;
&lt;pre&gt;{ 
  "twitter": { "key": "xxx", "secret": "xxx" },
  "db_host": "swan.mongohq.com",
  "db_port": "27080",
  "db_username": "user",
  "db_password": "pass
}&lt;/pre&gt;</description><link>http://blog.jschat.org/post/486260335</link><guid>http://blog.jschat.org/post/486260335</guid><pubDate>Wed, 31 Mar 2010 04:28:00 -0400</pubDate></item><item><title>Protocol Changes</title><description>&lt;p&gt;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&amp;#8217;s at the top level instead:&lt;/p&gt;
&lt;p&gt;&lt;code&gt;{ 'display' =&amp;gt; 'message', 'message' =&amp;gt; { ... }, 'time' =&amp;gt; 'Tue Mar 30 15:17:02 UTC 2010' }&lt;/code&gt;&lt;/p&gt;</description><link>http://blog.jschat.org/post/484350556</link><guid>http://blog.jschat.org/post/484350556</guid><pubDate>Tue, 30 Mar 2010 11:17:28 -0400</pubDate></item><item><title>Gem Released</title><description>&lt;p&gt;I&amp;#8217;ve bundled JsChat into a gem so you can install it with:&lt;/p&gt;
&lt;p&gt;&lt;code&gt;gem install jschat&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;This makes it possible to run JsChat from the command line:&lt;/p&gt;
&lt;ul&gt;&lt;li&gt;&lt;code&gt;jschat-server&lt;/code&gt; - runs the server&lt;/li&gt;
&lt;li&gt;&lt;code&gt;jschat-web&lt;/code&gt; - runs a web app&lt;/li&gt;
&lt;li&gt;&lt;code&gt;jschat-client&lt;/code&gt; - runs the console client&lt;/li&gt;
&lt;/ul&gt;&lt;p&gt;I&amp;#8217;ve also added config files.  They&amp;#8217;re in JSON format, and you need to double quote the keys.  The default locations are (client) &lt;code&gt;~/.jschat/config.json&lt;/code&gt; and (server) &lt;code&gt;/etc/jschat/config.json&lt;/code&gt;.&lt;/p&gt;</description><link>http://blog.jschat.org/post/463549457</link><guid>http://blog.jschat.org/post/463549457</guid><pubDate>Sun, 21 Mar 2010 13:00:00 -0400</pubDate></item><item><title>Stateless Protocol: Complete</title><description>&lt;p&gt;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.&lt;/p&gt;
&lt;p&gt;The protocol works like this:&lt;/p&gt;
&lt;ol&gt;&lt;li&gt;Connect to a server and send a JSON string with &lt;i&gt;protocol&lt;/i&gt; set to &lt;i&gt;stateless&lt;/i&gt;&lt;/li&gt;
&lt;li&gt;The server will send back a cookie&lt;/li&gt;
&lt;li&gt;On every subsequent request, provide the cookie&lt;/li&gt;
&lt;/ol&gt;&lt;p&gt;Here&amp;#8217;s a code example: &lt;a href="http://gist.github.com/234550"&gt;stateless_example.rb&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;One of the reasons for doing this is it cuts down the web app&amp;#8217;s complexity.  The old web app embedded an EventMachine module which maintained connections for each user with the server.&lt;/p&gt;
&lt;p&gt;This actually duplicates functionality that is already in the JsChat server, and goes against the grain of the way I intended JsChat to function.  The original approach made it difficult to run multiple web app processes (for example, with Passenger).&lt;/p&gt;
&lt;p&gt;JsChat is meant to be a very simple protocol that&amp;#8217;s easy to implement.  The EventMachine session management approach was just a hack I did, reusing code from the console client.&lt;/p&gt;
&lt;p&gt;The old web app was 440 lines of code, and it&amp;#8217;s now 264.&lt;/p&gt;</description><link>http://blog.jschat.org/post/243614758</link><guid>http://blog.jschat.org/post/243614758</guid><pubDate>Sat, 14 Nov 2009 08:35:43 -0500</pubDate></item><item><title>Stateless Protocol</title><description>&lt;p&gt;I&amp;#8217;m working on making the JsChat protocol stateless.  This means that the web client&amp;#8217;s complexity will be greatly reduced in the future.&lt;/p&gt;
&lt;p&gt;I&amp;#8217;m going to make the stateless mode optional, so clients can connect using sockets or single requests.&lt;/p&gt;</description><link>http://blog.jschat.org/post/234852031</link><guid>http://blog.jschat.org/post/234852031</guid><pubDate>Fri, 06 Nov 2009 05:49:28 -0500</pubDate></item><item><title>Clojure Bot</title><description>&lt;p&gt;Here&amp;#8217;s an example of a bot written with Clojure: &lt;a href="http://gist.github.com/131415"&gt;Clojure JsChat Bot&lt;/a&gt;.  It might not be 100% idiomatic Clojure, but it shows that talking JsChat is simple in Clojure.&lt;/p&gt;
&lt;p&gt;Clojure comes bundled with JSON libraries for creating and parsing JSON.  The parser returns a PersistentArrayMap: &lt;code&gt;((parsed-json "message") "message")&lt;/code&gt; accesses the message body element of a JsChat message.&lt;/p&gt;</description><link>http://blog.jschat.org/post/125354460</link><guid>http://blog.jschat.org/post/125354460</guid><pubDate>Wed, 17 Jun 2009 14:57:11 -0400</pubDate></item><item><title>JavaScript Bots</title><description>&lt;p&gt;I&amp;#8217;ve made an example of a &lt;a href="http://gist.github.com/112520"&gt;JavaScript bot&lt;/a&gt; for JsChat.  You can run it using &lt;a href="http://www.mozilla.org/rhino/"&gt;Rhino&lt;/a&gt;, and it uses Java&amp;#8217;s sockets for connections:&lt;/p&gt;
&lt;p&gt;&lt;code&gt; $ rlwrap java -jar js.jar&lt;br/&gt; Rhino 1.7 release 2 2009 03 22&lt;br/&gt; js&amp;gt; load('bot.js') &lt;/code&gt;&lt;/p&gt;
&lt;p&gt;Notice how simple the code for interpreting the protocol is.  I&amp;#8217;ve used the same strategy as the JsChat client and server code, whereby methods are executed based on the hashes returned from the server: &lt;code&gt;JsChat.Responses.Display[json.display]&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;
&lt;script src="http://gist.github.com/125775.js"&gt;&lt;/script&gt;&lt;/p&gt;</description><link>http://blog.jschat.org/post/119904948</link><guid>http://blog.jschat.org/post/119904948</guid><pubDate>Mon, 08 Jun 2009 07:59:28 -0400</pubDate></item><item><title>Kev and his Emotes</title><description>&lt;p&gt;&lt;img src="http://dl.getdropbox.com/u/221414/blogs/jschat/emotes.png"/&gt;&lt;/p&gt;
&lt;p&gt;Kev originally wanted us to build JsChat about 3 years ago.  We haven&amp;#8217;t quite implemented his idea yet (which was about monetizing IRC-style chat), but he&amp;#8217;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.&lt;/p&gt;
&lt;p&gt;I just updated the web app with a command so you can list all of them.  Next time you&amp;#8217;re in the web app, type &lt;b&gt;/emotes&lt;/b&gt; and you&amp;#8217;ll get a list of available emoticons.&lt;/p&gt;</description><link>http://blog.jschat.org/post/116729151</link><guid>http://blog.jschat.org/post/116729151</guid><pubDate>Tue, 02 Jun 2009 06:00:03 -0400</pubDate></item><item><title>Passenger/Rack Support</title><description>&lt;p&gt;&lt;img src="http://dl.getdropbox.com/u/221414/blogs/jschat/logo-trans.png"/&gt;&lt;/p&gt;
&lt;p&gt;I&amp;#8217;ve just checked in &lt;a href="http://modrails.com/"&gt;Passenger&lt;/a&gt; and Rack support with a config.ru sample into the &lt;a href="http://github.com/alexyoung/jschat/"&gt;JsChat repo&lt;/a&gt;.  It should now be easy to get JsChat working with Passenger if you use it on your servers.&lt;/p&gt;
&lt;p&gt;I also made message submissions display in &lt;b&gt;realtime&lt;/b&gt; in the web app&amp;#8217;s chat transcript.  This means there&amp;#8217;s instant feedback when a message is posted.&lt;/p&gt;</description><link>http://blog.jschat.org/post/116356981</link><guid>http://blog.jschat.org/post/116356981</guid><pubDate>Mon, 01 Jun 2009 14:22:43 -0400</pubDate></item><item><title>JsChat: Polling</title><description>&lt;p&gt;People are repeatedly joining #jschat talking about the merits of polling.  Please read this before you do that, or you&amp;#8217;re likely to get ignored:
&lt;/p&gt;&lt;ul&gt;&lt;li&gt;Yes, I know about server-sent events and flash hacks that provide sockets&lt;/li&gt;
&lt;li&gt;No, we&amp;#8217;re not going to use &lt;a href="http://juggernaut.rubyforge.org/"&gt;Juggernaut&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;JsChat will gradually support native server-sent events (some browsers provide this already)&lt;/li&gt;
&lt;li&gt;I used polling because it works on more devices and is cleaner&lt;/li&gt;
&lt;li&gt;The web interface is only &lt;b&gt;a small part of the system&lt;/b&gt;&lt;/li&gt;
&lt;li&gt;Stop to consider the thought that&amp;#8217;s been put into other aspects of the web interface&lt;/li&gt;
&lt;/ul&gt;</description><link>http://blog.jschat.org/post/114748445</link><guid>http://blog.jschat.org/post/114748445</guid><pubDate>Fri, 29 May 2009 04:50:00 -0400</pubDate></item><item><title>JsChat: Introduction</title><description>&lt;p&gt;&lt;a href="http://jschat.org"&gt;JsChat&lt;/a&gt; is a protocol for real-time chat based on JSON.  This makes it easy to build servers, clients, bots, and web-native applications.&lt;/p&gt;
&lt;p&gt;The protocol is currently evolving:  JsChat is implemented as a proof of concept as both a web and console client.&lt;/p&gt;
&lt;h3&gt;Server&lt;/h3&gt;
&lt;p&gt;The server is written with Ruby and includes unit tests.&lt;/p&gt;
&lt;h3&gt;Console Client&lt;/h3&gt;
&lt;p&gt;The console client is meant to be similar to irssi.  Typing /help will show available commands.  It uses Ncurses and is written with Ruby.&lt;/p&gt;
&lt;h3&gt;Web Client&lt;/h3&gt;
&lt;p&gt;The web client must be run alongside a server.  The design principles are:&lt;/p&gt;
&lt;ul&gt;&lt;li&gt;&lt;b&gt;Simple interface&lt;/b&gt;&lt;/li&gt;
&lt;li&gt;&lt;b&gt;Dynamic features&lt;/b&gt;: tab complete, URL autolinking, image URLs display inline, YouTube video URLs automatically display as embedded videos&lt;/li&gt;
&lt;li&gt;&lt;b&gt;Portability&lt;/b&gt;: only simple Ajax calls are relied on so it will run on most platforms and browsers (iPhone, etc)&lt;/li&gt;
&lt;/ul&gt;&lt;h3&gt;Protocol Design&lt;/h3&gt;
&lt;p&gt;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.&lt;/p&gt;
&lt;ul&gt;&lt;li&gt;Current commands are: display, change&lt;/li&gt;
&lt;li&gt;Messages take this format: { &amp;#8216;display&amp;#8217; =&amp;gt; &amp;#8216;message&amp;#8217;, &amp;#8216;message&amp;#8217; =&amp;gt; { &amp;#8216;to&amp;#8217; =&amp;gt; &amp;#8216;#room&amp;#8217;, &amp;#8216;message&amp;#8217; =&amp;gt; &amp;#8216;This is a message&amp;#8217; }&lt;/li&gt;
&lt;li&gt;Time stamps can be included in messages to aid clients&lt;/li&gt;
&lt;/ul&gt;&lt;p&gt;This syntax makes it easy to create classes that interpret the protocol.  Consider how simple this would be in JavaScript:&lt;/p&gt;
&lt;p&gt;&lt;code&gt;Display = {   message: function(message) { ... } } Display[json['display']] &lt;/code&gt;&lt;/p&gt;
&lt;h3&gt;Code&lt;/h3&gt;
&lt;p&gt;Get the code from my &lt;a href="http://github.com/alexyoung/jschat/"&gt;GitHub repository&lt;/a&gt;.&lt;/p&gt;
&lt;h3&gt;Next&lt;/h3&gt;
&lt;p&gt;Over the next few week, I&amp;#8217;ll post here with tutorials and tips on how to install JsChat and manage the server-side daemons.  It&amp;#8217;s running on jschat.org with Ruby 1.8, Apache and mod_proxy.&lt;/p&gt;</description><link>http://blog.jschat.org/post/113904398</link><guid>http://blog.jschat.org/post/113904398</guid><pubDate>Wed, 27 May 2009 15:42:24 -0400</pubDate></item></channel></rss>

