TNChat

TNChat is a client/server chat system developed in PHP (the server) and XUL (the client). There is also a Flash version of the client.

The Server

 * Main article: TNChat Server

The Client

 * Main article: TNChat Client

The latest TNChat client is a XULRunner application written entirely using XUL and JavaScript. Updates can generally be found in my blog's "Projects" category.

The current version, as of 2008-04-07, is version 0.3.1.

The Protocol
The protocol is very simple, it can be spoken by anyone with access to telnet.

As a rule of thumb: anything that starts with / is a command. Anything else is chat text.

Messages sent by the server end each line with \n\0 (for compatibility with Flash). Messages sent by the client end in \n, with optional \r before it.

/nick
Type: client to server.

Syntax: /nick [nickname]

where [nickname] is any string. If your nickname contains spaces, they will be transformed to underscores (the "_" character).

Details: This is the very first command to send upon connection. If you do not, you will not be able to send any messages. If you attempt to send messages, you will be told: &lt;System&gt; Bad nickname: already taken.

/userlist
Type: client to server.

Syntax: /userlist

Details: This is, very probably, the second command to send, if you've implemented userlist handling in your client. It causes the server to immediately send you a list of /joins (see below), one on each line, for each of the users currently online. You may use this to build your initial user list.

This command also marks your connection as "userlist-capable", and the server will then continue to send /join and /part messages for each user to join/part until you disconnect.

Will probably be replaced by a /capa command in future versions.

/help
Type: client to server.

Syntax: /help

Details: This command will cause the server to tell you (and only you) what commands it knows. In future, it will probably provide further assistance, as well.

Please note that a few commands, such as /userlist, are left out of the list on purpose. The reason for this is that these are special commands, not meant to be randomly disseminated. If you're reading this, you're getting the full listing (as of the latest revision).

/me
Type: client to server.

Syntax: /me [text]

where [text] is any string ending with a newline.

Details: The standard /me command from IRC and many other places. Causes the server to print: -&gt; [your nickname] [text] thereby allowing you to say, for example, "Narc yawns" (/me yawns).

/buzz
Type: both (client to server and server to client).

Syntax: From client: /buzz

From server: /buzz [nickname] where [nickname] is the nickname of the person who initiated the /buzz.

Details: When sent to the server, the /buzz command is disseminated to all clients together with the nickname of the person who initially sent it. It is up to the client to decide what to do with it.

In the current TNChat client, /buzz, when received, causes the client to play a loud noise. This feature was inspired by Yahoo! Messenger, which provides it as a means of getting the other user's attention.

/quit
Type: client to server.

Syntax: /quit

Details: Causes the connection to be immediately closed by the server.

/debug
Type: client to server.

Syntax: /debug {c|k|s|ss}

Details: /debug</tt> provides... debug information:


 * /debug c</tt> will give connection information.
 * /debug k</tt> will tell you the connection's id number inside the connections array.
 * /debug s</tt> will print the server application's state.
 * /debug ss</tt> will print the underlying server framework's state.

/debug</tt> is a hack that will be removed when no longer necessary. The messages it sends are sent only to the asking user.

/join
Type: server to client; client must have the userlist capability (see /userlist</tt> above).

Syntax: /join [nickname] where [nickname] is the nickname of the user who has just joined.

Details: Automatically sent by the server to all clients with the userlist capability when a new user connects and identifies (with /user</tt>).

It is also automatically sent as soon as a client declares the userlist capability for each user currently online, to allow the client application to build its current users listing.

/part
Type: server to client; client must have the userlist capability (see /userlist</tt> above)

Syntax: /part [nickname] where [nickname] is the nickname of the user who has just parted.

Details: Automatically sent to all clients who have declared the userlist capability when a user parts (disconnects, /quit</tt>s, or otherwise) as soon as the server detects the occurence.

Note that the server is not totally reliable in detecting parted clients, particularly when they disconnect because of network failure, and thus it is possible for some of the users on the active list to be offline, just not detected yet. However, if the TCP connection terminates gracefully (by either side closing the connection), this will be detected instantly.

There is a planned /ping</tt> command, to be replied to with /pong</tt>, to be sent every minute of inactivity by the server, with the server assuming, if it has not received a /pong</tt> in 15 seconds after its /ping</tt>, that the client has been disconnected. However, this would require some additions to the current server architecture, and is not yet a priority. For now, you'll have to just deal with it.