Пример #1
0
function displayLASQueries($LASHost, &$result)
{
    if (!connectToLAS($LASHost, $fp, $result)) {
        $result = "Failed to connect to LAS {$LASHost} (ec 12)";
        return false;
    }
    // send the message that say that we want to add a user
    $msgout = new CMemStream();
    $fake = 0;
    $msgout->serialuint32($fake);
    // fake used to number the packet
    $messageType = 2;
    $msgout->serialuint8($messageType);
    if (!sendMessage($fp, $msgout)) {
        $result = "Failed to send query to LAS {$LASHost} (ec 13)";
        return false;
    }
    if (!waitMessage($fp, $msgin)) {
        $result = "Failed to wait for LAS {$LASHost} (ec 14)";
        return false;
    }
    $result = '';
    if (!$msgin->serialstring($result)) {
        $result = "Failed to decode LAS message {$LASHost} (ec 15)";
        return false;
    }
    fclose($fp);
    $pos = strpos($result, ':');
    if ($pos === FALSE) {
        $result = "Failed to decode LAS message {$LASHost} (ec 16)";
        return false;
    }
    $success = substr($result, 0, $pos) == '1';
    if ($success) {
        ++$pos;
        $npos = strpos($result, "\n", $pos);
        $result = substr($result, $npos);
    } else {
        $result = substr($result, $pos + 1);
    }
    return $success;
}
Пример #2
0
function queryToAS($rawvarpath, &$result, $asAddr, $asPort)
{
    global $nel_queries;
    $nel_queries[] = $rawvarpath;
    $ok = false;
    connectToAS($fp, $result, $asAddr, $asPort);
    if (strlen($result) != 0) {
        return $ok;
    }
    // send the message that say that we want to add a user
    $msgout = new CMemStream();
    $fake = 0;
    $msgout->serialuint32($fake);
    // fake used to number the packet
    $messageType = 0;
    $msgout->serialuint8($messageType);
    $msgout->serialstring($rawvarpath);
    sendMessage($fp, $msgout);
    waitMessage($fp, $msgin);
    $msgin->serialstring($result);
    if (strlen($result) == 0) {
        // it failed
    } else {
        // it's ok
        $ok = true;
    }
    disconnectFromAS(&$fp);
    return $ok;
}
Пример #3
0
function disconnectClient($shardid, $uid, &$res)
{
    $ok = false;
    connectToLS($fp, $res);
    if (strlen($res) != 0) {
        return $ok;
    }
    // send the message that say that we want to add a user
    $msgout = new CMemStream();
    $fake = 0;
    $msgout->serialuint32($fake);
    // fake used to number the packet
    $messageType = 1;
    $msgout->serialuint8($messageType);
    $msgout->serialuint32($shardid);
    $msgout->serialuint32($uid);
    if (!sendMessage($fp, $msgout)) {
        $res = "Can't send message disconnect to the Login Service (error code 47)";
        return $ok;
    }
    if (!waitMessage($fp, $msgin)) {
        $res = "Can't receive the answer from the Login Service (error code 48)";
        return $ok;
    }
    if (!$msgin->serialstring($res)) {
        $res = "Can't read the string (error code 49)";
        return $ok;
    }
    $ok = true;
    //printf("receive response '$reason' '$cookie' '$addr'<br>");
    fclose($fp);
    //echo "sent OK.<br><br>";
    return $ok;
}