if (!$result["success"]) { var_dump($result); exit; } echo "Ready.\n"; $tracker = array(); do { $result = $wsserver->Wait(); // Do something with active clients. foreach ($result["clients"] as $id => $client) { if (!isset($tracker[$id])) { echo "Client ID " . $id . " connected.\n"; // Example of checking for an API key. $url = HTTP::ExtractURL($client["url"]); if (!isset($url["queryvars"]["apikey"]) || $url["queryvars"]["apikey"][0] !== "123456789101112") { $wsserver->RemoveClient($id); } else { echo "Valid API key used.\n"; } $tracker[$id] = array(); } // This example processes the client input (add/multiply two numbers together) and sends back the result. $ws = $client["websocket"]; $result2 = $ws->Read(); while ($result2["success"] && $result2["data"] !== false) { $data = json_decode($result2["data"]["payload"], true); $question = $data["pre"] . " " . $data["op"] . " " . $data["post"]; if ($data["op"] === "+") { $answer = $data["pre"] + $data["post"]; } else { if ($data["op"] === "-") {