RealChat Software

6.2. RealChat Server API



General Information

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

You can access these commands using 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 a local host only. You can also access the server API commands through a standard browser HTTP request; for example, http://localhost:10010/?api.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, 2);
	if(!$fp) {
		echo "$errstr ($errno)\n";
	} else {
		fputs($fp,"GET /?".$apiCommand." HTTP/1.0\n\n");
		$header = true;
		while(!feof($fp)) {
			$line = fgets($fp,128);
			if ( $header == false ) $result .= $line;
			if ( trim($line) == "" ) $header = false;
		}
		fclose($fp);
	}
	return $result;
}

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

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

Available Commands

Time
Returns the current server time.
IncomingTraffic, api.OutingTraffic
Returns the current server incoming and 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.

By default all API commands return information for the first, or default, virtual server. If you want to check a specific virtual server, add server=serverName; for example,
api.server=Virtual03,UserCount will return the number of users connected to Virtual03 chat server.




Contents | Parent Topic | Previous Topic | Next Topic