• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

how WOULD i write this in Cold Fusion?

Explorer ,
Apr 26, 2006 Apr 26, 2006

Copy link to clipboard

Copied

This is a PHP function that shows me how many users are in my chatroom, but I don't know how to do this in Cold Fusion. I need to in order to see who's in my chat room. Any ideas on how I'd do this?

Here's the working PHP code

<?
$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" );
$PeopleInRoom = getServerAPI("api.PeopleInRoom=The%20Lobby" );

echo "<b>Users Online Now:</b> ".$PeopleInRoom."<br><br>";
?>
TOPICS
Advanced techniques

Views

338

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Explorer , Apr 27, 2006 Apr 27, 2006
thank you! worked like a charm.

Votes

Translate

Translate
Participant ,
Apr 27, 2006 Apr 27, 2006

Copy link to clipboard

Copied

Not PHP person. But from the common logic point's of view, it looks like they execute HTTP "GET" request to the local host.

Something like:

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

should be

<cfhttp method="get" url=" http://localhost/?api.UserCount" port="10010">

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Apr 27, 2006 Apr 27, 2006

Copy link to clipboard

Copied

LATEST
thank you! worked like a charm.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation