public static function GetHandler($rawPacket) { if (XTParser::IsValid($rawPacket)) { $arrPacket = XTParser::ParseRaw($rawPacket); if (isset($arrPacket[1])) { $strHandler = $arrPacket[1]; return $strHandler; } } return false; }
private function handleLogin($strResult) { $arrPacket = XTParser::ParseRaw($strResult); if ($arrPacket[1] == 'e') { $intError = $arrPacket[3]; $strError = $this->arrErrors[$intError]['Description']; throw new ConnectionException($strError, $intError); } $strVertical = $arrPacket[3]; $arrVertical = XTParser::ParseVertical($strVertical); $this->intPlayerId = $arrVertical[0]; $this->strLoginKey = $arrVertical[3]; $this->strConfirmationKey = $arrPacket[4]; $this->strRawPlayer = $strVertical; return true; }
$username = $_POST["username"]; $password = $_POST["password"]; spl_autoload_register(function ($strClass) { require_once sprintf('Penguin/%s.php', $strClass); }); $objPenguin = new Penguin(); global $itemid; $objPenguin->addListener("jr", function ($packet) use($objPenguin) { $objPenguin->addItem($_POST["itemid"]); }); $objPenguin->addListener("ai", function ($packet) { echo "Successfully added item ", "\n"; die; }); $objPenguin->addListener("e", function ($packet) use($objPenguin) { die($objPenguin->arrErrors[$packet[3]]["Description"]); }); try { $objPenguin->login($username, $password); $objPenguin->joinServer('Sled'); } catch (ConnectionException $objException) { die; } $objPenguin->joinRoom(805); while (true) { $strData = $objPenguin->recv(); if (XTParser::IsValid($strData)) { // echo $strData, chr(10); } } }