RealChat Software 2.0

4.1. RealChat Client API



General Information

There is a set of commands which you can use to communicate with RealChat Client applet, and spice up your chatroom. You access these commands via JavaScript embedded in your client HTML pages. You may take a look at the Example 3 for an idea of what you can do with the API commands.

How this works ( an example )

Let's say you have the following code somewhere in your client HTML page:

<script type="text/javascript">
<!--
function join( roomName ) {
	ChatClient.changeRoom( roomName );
}
//-->
</script>

<applet 
  codebase = "."
  archive  = "RealChat.jar"
  code     = "rcs.client.RealChatClient.class"
  name     = "ChatClient"
  width    = "500"
  height   = "400"
  MAYSCRIPT>

    .
    .

</applet>

<a href="javascript:join('The Lobby');">Go to The Lobby</a>
When the user clicks on the 'Go to The Lobby' link he/she will be put into 'The Lobby' room.

Available Commands

setChatText( message )
Sets the text of the chat input field to message. Note that the chat client will automatically replace the first occurance of the token "_USER_" with the currently selected user name, and the first occurance of the token "_ME_" with the name the client is currently connected as. For example:

ChatClient.setChatText( 'Hi _USER_, how are you doing?' );
ChatClient.setChatText( 'My name is _ME_.' );
sendMessage( message )
Same as the above, but will automatically sends message.
getSelectedUser()
Returns the currently selected user name. For example:

var selectedUser = ChatClient.getSelectedUser();
myName()
Returns the name the client is currently connected as.
getCurrentRoom()
Returns the name of current room.
changeRoom( roomName )
Changes the room.




Contents | JTAN Members Area