function requestProcessor($request) { echo "received request" . PHP_EOL; var_dump($request); if (!isset($request['type'])) { return "ERROR: unsupported message type"; } switch ($request['type']) { /* case "login": //return doLogin($request['username'],$request['password']); $auth=doLogin($request['username'],$request['password']); if($auth==true){ return array('hello'=>'world'); } */ //case "validate_session": //return doValidate($request['sessionId']); //in case friends this will return a list of friends from //the the steam user, and send it in an array to the client. case "showFriends": //echo "hello"; //echo $request['steamid']; //print_r("yo"); return showFriends($request['steamid']); break; case "showFriends2": //echo "hello"; //echo $request['steamid']; //print_r("yo"); return showFriends($request['steamid']); break; case "fofLoad": return compareGames("76561198011789036", "76561197978534933"); break; //return array("returnCode" => '0', 'message'=>"Server received request and processed"); } //return array("returnCode" => '0', 'message'=>"Server received request and processed"); }
function send($type, $sid, $sid2) { //echo "function called"; //echo $sid; $client = new rabbitMQClient("testRabbitMQ.ini", "testServer"); /* if (isset($argv[1])) { $msg = $argv[1]; } else { $msg = "test message"; } */ $request = array(); $request['type'] = "{$type}"; //echo "<br>"; //echo $request['type']; ///echo "<br>"; //echo "array created"; $request['steamid'] = "{$sid}"; $request['steamid2'] = "{$sid2}"; //echo $request['steamid']; //$request['password'] = "******"; //$request['message'] = $msg; $response = $client->send_request($request); //echo "request sent"; //$response = $client->publish($request); $i = 0; $playerid = ""; if ($type == 'showFriends') { //echo $response[3]; foreach ($response as $em) { //echo $em; //echo "<br>"; if ($i == 0) { //echo "<br>"; echo "<img src={$em}>"; echo "\r\n"; $i++; } elseif ($i == 1) { //echo gettype($em); $playerid = (string) $em; //echo $playerid; $i++; } else { //print_r($playerid); echo "<a href= 'fofLoad.php?sid={$playerid}'>'{$em}'</a>"; echo "<br>"; //echo $playerid; $i = 0; } } } if ($type == 'showFriends2') { //echo $response[3]; foreach ($response as $em) { //echo $em; //echo "<br>"; if ($i == 0) { //echo "<br>"; echo "<img src={$em}>"; echo "\r\n"; $i++; } elseif ($i == 1) { //echo gettype($em); $playerid = (string) $em; //echo $playerid; $i++; } else { //$gamecount2=compareGames("76561197978534933","76561198011789036"); //echo $gamecount2; //print_r($playerid); echo "{$em}" . " has " . compareGames($playerid, "76561198011789036") . " games in common"; echo "<br>"; //echo $playerid; $i = 0; } } } if ($type == 'fofLoad') { var_dump($response); } //echo "client received response: ".PHP_EOL; //print_r($response); //echo "\n\n"; //echo $argv[0]." END".PHP_EOL; }