Common subdirectories: chatroom/chatroom_appbar and chatroom_new/chatroom_appbar
diff -up chatroom/chatroom.forms.inc chatroom_new/chatroom.forms.inc
--- chatroom/chatroom.forms.inc	2010-07-09 09:15:16.000000000 +0200
+++ chatroom_new/chatroom.forms.inc	2011-01-09 00:15:37.954359928 +0100
@@ -195,6 +195,12 @@ function chatroom_admin_settings() {
     '#default_value' => variable_get('chatroom_chat_date_format', '* \S\e\n\t \a\t G:i'),
     '#description' => t('Format for system time messages in chats. See the <a href="@url">PHP manual</a> for available options. This format is currently set to display as <span>%date</span>.', array('@url' => 'http://php.net/manual/function.date.php', '%date' => format_date(time(), 'custom', variable_get('chatroom_chat_date_format', '* \S\e\n\t \a\t G:i')))),
   );
+  $form['chatroom_allow_anon_name'] = array(
+    '#type' => 'checkbox',
+    '#title' => t('Provide a name field for anonymous users?'),
+    '#description' => t('Like other chat type services, this adds a name textfield for anonymous users.'),
+    '#default_value' => variable_get('chatroom_allow_anon_name', TRUE),
+  );
   if (module_exists('smileys')) {
     $form['chatroom_smileys_support'] = array(
       '#type' => 'fieldset',
diff -up chatroom/chatroom.install chatroom_new/chatroom.install
--- chatroom/chatroom.install	2010-07-13 15:08:38.000000000 +0200
+++ chatroom_new/chatroom.install	2011-01-08 02:41:44.446361536 +0100
@@ -305,6 +305,10 @@ function chatroom_schema() {
         'type' => 'text',
         'size' => 'big',
       ),
+      'anonname' => array(
+        'type' => 'text',
+        'size' => 'big',
+      ),
       'sid' => array(
         'type' => 'varchar',
         'length' => '64',
diff -up chatroom/chatroom.js chatroom_new/chatroom.js
--- chatroom/chatroom.js	2010-07-08 05:35:41.000000000 +0200
+++ chatroom_new/chatroom.js	2011-01-08 03:05:40.818361273 +0100
@@ -44,8 +44,12 @@ Drupal.behaviors.chatroom = function(con
 
   $('#edit-chatroom-message-entry-box').keyup(function(e) { 
     var messageText = $('#edit-chatroom-message-entry-box').val().replace(/^\s+|\s+$/g, '');
+    var anonNameText = '';
+    if ($('#edit-chatroom-anon-name').length) {
+      anonNameText = $('#edit-chatroom-anon-name').val().replace(/^\s+|\s+$/g, '');
+    }
     if (messageText && e.keyCode == 13 && !e.shiftKey && !e.ctrlKey) {
-      Drupal.chatroom.postMessage(messageText);
+      Drupal.chatroom.postMessage(messageText, anonNameText);
       $('#edit-chatroom-message-entry-box').val('').focus();
     }
     else {
@@ -56,8 +60,12 @@ Drupal.behaviors.chatroom = function(con
     e.preventDefault();
     e.stopPropagation();
     var messageText = $('#edit-chatroom-message-entry-box').val().replace(/^\s+|\s+$/g, '');
+    var anonNameText = '';
+    if ($('#edit-chatroom-anon-name').length) {
+      anonNameText = $('#edit-chatroom-anon-name').val().replace(/^\s+|\s+$/g, '');
+    }
     if (messageText) {
-      Drupal.chatroom.postMessage(messageText);
+      Drupal.chatroom.postMessage(messageText, anonNameText);
       $('#edit-chatroom-message-entry-box').val('').focus();
     }
   });
@@ -211,13 +219,14 @@ Drupal.chatroom.scrollToLatestMessage =
   $('.new-message').removeClass('new-message');
 }
 
-Drupal.chatroom.postMessage = function(message) {
+Drupal.chatroom.postMessage = function(message, anonName) {
+  //console.log('posting message: '+message);
   $.ajax({
     type: 'POST',
     url: Drupal.settings.basePath + Drupal.settings.chatroom.postMessagePath + '/' + Drupal.settings.chatroom.chatId + '/' + Drupal.settings.chatroom.latestMsgId,
     dataType: 'json',
     success: Drupal.chatroom.pollHandler,
-    data: { message: message } 
+    data: { message: message, anonname: anonName }
   })
 }
 
diff -up chatroom/chatroom.module chatroom_new/chatroom.module
--- chatroom/chatroom.module	2010-07-15 02:15:10.000000000 +0200
+++ chatroom_new/chatroom.module	2011-01-09 00:20:47.802361588 +0100
@@ -1012,9 +1012,8 @@ function chatroom_chat_load_messages_hel
   $messages = array();
   $guest_sids = array();
   while ($message = db_fetch_object($result)) {
-    if ($message->uid == 0 && !in_array($message->sid, $guest_sids)) {
+    if ($message->uid == 0) {
       $guest_sids[] = $message->sid;
-      $message->name = variable_get('chatroom_guest_user_prefix', t('guest-'));
     }
     $messages[$message->cmid] = $message;
   }
@@ -1026,7 +1025,11 @@ function chatroom_chat_load_messages_hel
       foreach ($messages as $message) {
         if ($message->sid == $guest->sid) {
           $messages[$message->cmid]->guest_id = $guest->guest_id;
-          $messages[$message->cmid]->name .= $guest->guest_id;
+          if ($message->anonname && variable_get('chatroom_allow_anon_name', TRUE)) {
+            $messages[$message->cmid]->name = $message->anonname .' <span class="anon-label">('. variable_get('chatroom_guest_user_prefix', t('guest-')) . $guest->guest_id .')</span>';
+          } else {
+            $messages[$message->cmid]->name = variable_get('chatroom_guest_user_prefix', t('guest-')) . $guest->guest_id;
+          }
         }
       }
     }
@@ -1259,6 +1262,7 @@ function chatroom_chat_post_message($nod
     'ccid' => $node->chat->nid, 
     'uid' => $user->uid, 
     'msg' => $_POST['message'],
+    'anonname' => $_POST['anonname'],
     'sid' => session_id(), 
     'msg_type' => chatroom_chat_get_message_type($_POST['message']),
     'recipient_uid' => 0, 
diff -up chatroom/chatroom.theme.inc chatroom_new/chatroom.theme.inc
--- chatroom/chatroom.theme.inc	2010-07-09 15:19:46.000000000 +0200
+++ chatroom_new/chatroom.theme.inc	2011-01-09 00:16:45.466359844 +0100
@@ -351,6 +351,14 @@ function theme_chatroom_chat_make_privat
  * @return array
  */
 function chatroom_chat_buttons($form_state, $node) {
+  if (!$GLOBALS['user']->uid && variable_get('chatroom_allow_anon_name', TRUE)) {
+    $form['chatroom_anon_name'] = array(
+      '#type' => 'textfield',
+      '#title' => t('Enter your name'),
+      '#size' => 20,
+      '#maxlength' => variable_get('chatroom_max_message_size', 1000),
+    );
+  }
   $form['chatroom_message_entry_box'] = array(
     '#type' => 'textarea',
     '#title' => t('Enter your message text here'),
Common subdirectories: chatroom/po and chatroom_new/po
