RealChat Software 2.0

4.2. RealChat Server API



General Information

There is a set of commands which you can use to pull up infromation from RealChat Server. For example you may show your visitors who is ONLINE via an ASP or PHP page before they enter the chat or gather monitoring information for the server. You can also create a script, that dynamically checks to see if a specific user ( sales representative for example ) is online, and if so displays a link to the on the Rep's chat room.

You can access these commands via any server-parsed HTML tools such as ASP, PHP, Perl, or whatever you like. They are served by the built in HTTP control server and are accessible from localhost only. You can also access the server API commands through standard browser HTTP request e.g. http://localhost:10010/?api.server=your_vserver_label,Time will return the current server time.

Important note: This feature may slow down your chat server, as it connects to the server each time a visitor to your site opens a page which contains API calls. Use with care.

How this works ( an example )

It's a matter of including an external URL within your HTML response. This PHP example will display the currently connected users and a list of available rooms for this chat server.

<?
$port = 10010;
function getServerAPI( $apiCommand ) {
	global $port;
	$result = "";
	$fp = fsockopen("localhost", $port, &$errno, &$errstr, 30);
	if(!$fp) {
		echo "$errstr ($errno)\n";
	} else {
		fputs($fp,"GET /?".$apiCommand." HTTP/1.0\n\n");
		while(!feof($fp)) {
			$result .= fgets($fp,128);
		}
		fclose($fp);
	}
	return $result;
}

$userCount = getServerAPI( "api.server=your_vserver_label,UserCount" );
$roomList = getServerAPI( "api.server=your_vserver_label,RoomList" );

echo "Users conected: ".$userCount."<br><br>";
echo "Available rooms:<PRE>".$roomList."</PRE>";
?>

Available Commands

Time
Returns the current server time.
IncomingTraffic, OutingTraffic
Returns the current server incoming / outgoing traffic.
TotalUserCount
Returns the total server user count.
UserCount
Returns the number of users connected to this server.
RoomCount
Returns the number of rooms available for this server.
RoomList
Returns a list of available rooms for this server.
RoomListWithCounts
Returns a list of available rooms for this server and the number of users in each room.
PeopleInRoom=roomName
Returns a list of all users in roomName.
WhereIs=user
Returns the room where user is.

You must always use "api.server=your_vserver_label,Command" to access API commands. Replace your_vserver_label with the label you chose for your vServer in the Members Area. Replace Command with one of the commands listed above.




Contents | JTAN Members Area