Chat/MUD 0.2

Version 0.2 | Project Home

http://rumfish.net/chat (Try the new one, it is much better)

http://rumfish.net/chat/old.php (still up for reference only)

Currently in (very) early development, this should grow into a chat application and MUD (multi user text based RPG) platform for the site....I hope

It is being built using AJAX (Asymmetrical JavaScript and XML), a technique used in several Google applications to offer a desktop like experience in a browser.

Progress Log

 * 12/26/2005 3:12 AM - Achieved server bounce. That is, while you can still only chat with your self, it now sends the message to the server and the server echos it back!  This might actually become usable over break....crosses fingers
 * 12/27/2005 5:09 PM - Auto check working and tested in IE, FF. Smart scroller also working in IE, FF.
 * 12/28/2005 11:57 PM - Data storage achieved! There are still some timing issues that cause repeat data, it should be possible to chat now (though names are currently ip addresses). w00t!
 * 12/29/2005 12:18 AM - Timing fixed, cross browser chat worked. Waiting for some one to help test it
 * 12/29/2005 12:48 AM - First test....successful!!!!!! (thanks LR)
 * 12/30/2005 12:21 AM - Now uses (and auto detects) forum username! Still allows Anonymous access, should be easy to fix.
 * 12/30/2005 2:54 AM - Added user list (currently displays all users logged on to forum)
 * 1/4/2006 12:42 AM - Rebuilding the whole thing to make it more reliable and expandable (using OOP with JavaScript) http://rumfish.net/chat/new.php
 * 1/4/2006 3:04 AM - Revision now up to the functionality of the original (with the exception of the user list) and doesn't exhibit the random drops of its predecessor. Currently only works in FF.  Also uses &lt;div&gt;s instead of &lt;textarea&gt;s
 * 1/4/2006 4:58 AM - The new version now works in IE6 and FF1.5 (should work in others as well). It has at least the same level of functionality as the old version in all areas, and more in some.  It even makes errors rare!

Current features

 * Chat (by IP)


 * it works (well, sort of, and only confirmed in IE6 and FF1.5)


 * Use forum user name


 * Uses a div instead of a text area, allowing rich formatting


 * Stores the last update time on the file system to reduce the database server load
 * This should keep the system from getting in trouble with 1&1
 * (we are not supposed to use the database for chat applications because of load issues, this should alleviate those, and speed the script up a little bit)

Planned features

 * Dynamically alter the interval checks


 * Auto purge database of stuff older than 15 min.
 * This feature wont be implemented for some time so that I have a log of usage to debug from and to get a better idea of how to change it


 * Add in command capabilities
 * Needed for MUD capabilities, private chatting (sayTo), moderating, and other fun stuff


 * Recognize forum markup
 * This would allow you to use the same smiles and text formatting you would use on the forum.

Commands
This is a draft of planned commands. This is in no way a finished (much less implemented) list


 * /say [...]


 * /pm [user] [...]
 * /whisper [user] [...]


 * /move [room]


 * /act [...]


 * /yell [...]
 * /global [...]
 * Admin only

Issues / Known Bugs

 * Overlapping calls Fixed
 * Symptoms:
 * Cause lost messages (not entered in DB)
 * Cause missed message (stored but not retrieved)


 * Request timeouts with single calls keep updates from occurring, need a time out system Fixed


 * Display error on rapid calls
 * Symptoms: When several calls are sent rapidly (2-3+/sec) they are received by the server but not shown on the sending clients system


 * HTML is directly passed
 * This would allow a malicious user to send code that could affect other users browsers (such as JavaScript)
 * This venerability should be minimized at the moment by the use of a text area, once we switch to using a div, this will become a serious issue


 * FF1.5 Crash
 * Still trying to find out what causes this one...

Code Reference
This, like the program it is describing, is a work in progress. It may not reflect the current version of the program, or it could describe future additions. In any case, it is here primarily as a reference for my self and any one else helping me, but if you find it useful, then that is good too.

r.php
  [Text] 

user.php
  [avatar] [level] [rank] [color]

Query String Reference
Request only:

r.php?t=[PHP time stamp]

Command/Say:

r.php?t=[PHP times stamp]&u=[user name]&c=[Command text]

Elelemts

 * text
 * Main chat window
 * Textarea
 * document.getElementById('text')
 * log
 * Log window (mostly for debuging)
 * Textarea
 * document.getElementById('log')
 * line
 * Text input box
 * Input, type=text
 * document.getElementById('line')
 * users
 * Not yet included
 * Selection Box (multi)

Globals

 * time
 * = new Date;


 * xmlhttp
 * XMLHttpRequest Object


 * isChecking
 * To prevent simultaneous checks


 * username


 * userhash
 * Currently unused, will be used to confirm a users ID without the need to pass cookies


 * sent
 * = []
 * Used to store a log of all said commands (by current user this session) for "up command" feature

Functions

 * say
 * Called on form submit
 * Global Variables:
 * Local Variables:
 * text
 * Element reference (text)
 * line
 * Element reference (line)
 * url
 * Functions:
 * send_request (url as text)
 * add_to_sent (line.value as text)
 * do_log (description and line.value as text)


 * do_say (line, user, time)
 * Adds text to the message box
 * Local Variables:
 * text
 * Element reference (text)
 * toScroll (bool)
 * oldScroll (int)


 * usr (name)
 * (removed uses, no longer needed)


 * do_log (text)
 * Adds text to the message box
 * Local Variables:
 * _log
 * Element reference (log)
 * toScroll (bool)
 * oldScroll (int)


 * send_request (url)
 * Adds text to the message box
 * Global Variables:
 * isChecking
 * xmlhttp
 * Functions:
 * send
 * sets xmlhttp.onreadystatechange


 * check
 * Adds text to the message box
 * Global Variables:
 * isChecking
 * Local Variables:
 * url
 * xmlhttp
 * Functions:
 * sets xmlhttp.onreadystatechange
 * send
 * do_log ('sent request' as text)


 * OnLoad
 * Called once
 * Adds text to the message box
 * Local Variables:
 * text
 * url
 * Element reference (text)
 * Functions:
 * send_request (url)
 * do_log ("First request sent")


 * send
 * Adds text to the message box
 * Global Variables:
 * xmlhttp
 * Local Variables:
 * error (in catch block)
 * Functions:
 * do_log (error as text)
 * add_to_sent (text)
 * Adds text to the message box
 * Global Variables:
 * sent [next]
 * Functions:
 * do_log ('added to sent')
 * keypress (e)
 * Currently for testing
 * Adds text to the message box
 * Functions:
 * do_log (e.which as text)


 * add_say_to (user)
 * Adds the sayTo:'[user]'  command to the say line.
 * this function will likely be replaced by a general purpose command adding function
 * Local Variables:
 * line
 * Element reference (line)


 * get_user (name)


 * show_user (name)

Functions

 * say ($text, $user)
 * Adds $text to the database ( INSERT INTO chat_log (time, user, message) VALUES (time, $user, $text) )
 * Variables:
 * $query
 * $result


 * get_posts_from_time ($time)
 * Returnts all messages posted after $time ( SELECT time, user, message FROM chat_log WHERE time > $time ORDER BY time )
 * Variables:
 * $query
 * $result

Tables
Used for general (or global) chat. The function of this table will likely change or be removed once we switch to a room based system.

This table will be used for private instant messages to be sent between users.

Queries

 * INSERT INTO chat_log (time, user, message) VALUES (time, $user, $text)
 * Used in say
 * SELECT time, user, message FROM chat_log WHERE time > $time ORDER BY time
 * Used in get_posts_from_time($time)