JavaZOOM Web Site jChatBox homepage
  Software
  
Installation
  
Configuration
  
Administration
  
User guide
  
API & Extension
  
License

<< back

- FLASH5+ Client -

• How does it work ?
FLASH5 client communicates to jChatBox XMLConnector service (server-side) through HTTP. FLASH5 sends HTTP GET requests to get chatroom information, to login/logout and to chat. XMLConnector returns standard XML formated responses that will be processed by the FLASH 5 client. FLASH5 includes an XML parser to process responses.
We provide some a script to convert parsed XML to FLASH5 variables.


FLASH5 chat client with jChatBox XML Connector Service

Script and FLASH5 variables :
We provide a script that converts jChatBox XML content to FLASH5 variables (Arrays and Objects) more convenient to FLASH5 designers. This script in included in the "jChatBoxXMLScript" layer.

chatroomsVector is an Array of objects : chatroomDesc. In a few words, it's the list of all chatrooms.

chatroomDesc is an object with the following properties :
name Name of the chatroom.
subject Subject of the chatroom.
date Opening date of the chatroom.
maxusers Maximum users allowed in the chatroom.
totalusers Number of users in the chatroom.
id Chatroom id (needed to login).
private Private message allowed (true or false).
refresh Refresh rate controlled by server-side.
userlist Userlist of the chatroom (Array of objects : user).
msgs Messages of the chatroom (Array of objects : msg).

msg is an object with the following properties :
date Date of the message.
from Sender of the message.
to Recipient of the message.
type Type of the message (1=join, 2=left, 3=private).
content Content of the message.

user is an object with the following properties :
name Name of the user.

Here is a FLASH5 sample script that reads chatrooms information :

/**
 * Displays all chatrooms info in a textfield named content_feed_display.
 * vector is an alias for chatroomsVector variable.
 */

function displayData(vector)
{
   content_feed_display = "";
   for (j=0;j<vector.length;j++)
   {
       chatroomDesc = vector[j];
       content_feed_display += "<p><font size=\"+2\">"+chatroomDesc.date+" "+chatroomDesc.id+"        "+chatroomDesc.name+" "+
        chatroomDesc.subject+" "+chatroomDesc.totalusers+"/"+chatroomDesc.maxusers+
        "</font></p>"
;
   }
}


Script and FLASH5 functions (API) :
In addition to objects allowing designer to manipulate chatrooms, we provide an API to integrate designer's User Interface with jChatBox script. The API is based on callbacks.



jChatBox ACTIONS jChatBox CALLBACKS
doManager() callbackManager(chatroomsVector)
doLogin(username, chatroomid) callbackLogin(chatroomDesc)
doChat(message,to) callbackChat(chatroomDesc)
doRefresh() callbackRefresh(chatroomDesc)
doLogout() callbackLogout(chatroomsVector)
doQuit() callbackQuit(chatroomsVector)

Here is a FLASH5 sample script using jChatBox API :

/**
* Callback matching to doChat.
* chatroom variable is the instance of the joined chatroomDesc.
*/

function callbackChat(chatroom)
{
   displayChat(chatroom);
}

/**
* User Interface : Displays chatroom messages in message_area.
*/

function displayChat(chatroom)
{
   messages_area = "";
   vector = chatroom.msgs;
   for (j=0;j<vector.length;j++)
   {
      msg = vector[j];
      if (msg.type == "1")
      {
           // Join messages.
           messages_area += "<p><font size=\"-2\">"+msg.date+"</font><font size=\"+2\">"+
           " ***"+msg.content+" has joined the chatroom</font></p>";
      }
      else if (msg.type == "2")
      {
           // Left messages.
           messages_area += "<p><font size=\"-2\">"+msg.date+"</font><font size=\"+2\">"+
           " ***"+msg.content+" has left the chatroom</font></p>";
      }
      else if (msg.type == "3")
      {
          // Private messages.
          messages_area += "<p><font size=\"-2\">"+msg.date+"</font><font size=\"+2\">"+
          " <b>&lt;"+msg.from+"&gt;</b> "+msg.content+"</font></p>";
      }
      else
      {
           // Normal messages.
           messages_area += "<p><font size=\"-2\">"+msg.date+"</font><font size=\"+2\">"+
           " <b>&lt;"+msg.from+"&gt;</b> "+msg.content+"</font></p>";
      }
   }
}

[News] [Applets] [Servlets] [Services] [Projects] [Links] [About]

Copyright © JavaZOOM 1999-2003

Java is a trademark of Sun Microsystems,Inc. All other company and/or product names are the property of their respective owners.