function initClientRequest($rc)
{
    for ($ix = 0; $ix < $rc; $ix++) {
        $request = new PlutonClientRequest();
        $requestList[$ix] = $request;
        $request->setRequestData("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx xxxxx xx");
    }
}
Exemple #2
0
#!/usr/bin/php
<?php 
$pc = new PlutonClient("phpClient");
$pc->initialize();
$clReq1 = new PlutonClientRequest();
$clReq2 = new PlutonClientRequest();
$req1 = "1234567890";
$req2 = "qwertyuiop";
$clReq1->setRequestData($req1);
if (!$pc->addRequest(SERVICE_KEY, $clReq1)) {
    print_r("addRequest Error! " . $pc->getFault() . "\n");
    exit(-1);
}
$clReq2->setRequestData($req2);
if (!$pc->addRequest(SERVICE_KEY, $clReq2)) {
    print_r("addRequest Error! " . $pc->getFault() . "\n");
    exit(-1);
}
// ExecuteAndWaitALL
$pc->executeAndWaitAll();
if ($pc->hasFault()) {
    print_r("Fault! " . $pc->getFault() . "\n");
    exit(-1);
}
$response = '';
$fault = $clReq1->getResponseData($response);
if ($fault != 0) {
    print_r("fault: " . $clReq1->getFaultText() . "\n");
    exit(1);
}
if ($response != $req1) {
#!/usr/local/bin/php
<?php 
$expected = "I expect this to be echo'd out";
$client = new PlutonClient('inprogress');
$client->initialize();
$request = new PlutonClientRequest();
$request->setRequestData($expected);
$request->setContext("echo.sleepMS", "3000");
$client->addRequest('system.echo.0.raw', $request);
$client->executeAndWaitSent();
if ($request->inProgress()) {
    print "Request is in progress - good\n";
} else {
    print "Request is NOT in progress - bad\n";
    exit(1);
}
$res = $client->executeAndWaitAny();
print "executeAndWaitAny returned {$res}\n";
if ($request->inProgress()) {
    print "Request is still in progress - bad\n";
    exit(2);
} else {
    print "Request is NOT in progress - good\n";
}
$responseData = null;
$request->getResponseData($responseData);
if ($responseData !== $expected) {
    print "Client test failed\n  expected: {$expected}\n  received: {$responseData}\n";
    exit(3);
} else {
    print "Client test successful\n";
#!/usr/local/bin/php
<?php 
function abortme($why, $excode)
{
    print "Attributes1 failed: {$why}\n";
    exit($excode);
}
$client = new PlutonClient('attributes');
$api = $client->getAPIVersion();
print "API={$api}\n\n";
print "Setting attributes\n";
$request = new PlutonClientRequest();
$request->setAttribute(PLUTON_NOWAIT_ATTR);
$request->setAttribute(PLUTON_NOREMOTE_ATTR);
$request->setAttribute(PLUTON_NORETRY_ATTR);
$request->setAttribute(PLUTON_KEEPAFFINITY_ATTR);
$request->setAttribute(PLUTON_NEEDAFFINITY_ATTR);
$request->setAttribute(PLUTON_ALL_ATTR);
print "Fetching attributes\n";
function checkAttribute($req, $name, $att, $val)
{
    $b = $req->getAttribute($att);
    if ($b != $val) {
        abortme("Attribute not as expected for {$name} as {$b} != {$val}", 1);
    }
    print "{$name}={$b} ok\n";
}
checkAttribute($request, "PLUTON_NOWAIT_ATTR", PLUTON_NOWAIT_ATTR, 1);
checkAttribute($request, "PLUTON_NOREMOTE_ATTR", PLUTON_NOREMOTE_ATTR, 1);
checkAttribute($request, "PLUTON_NORETRY_ATTR", PLUTON_NORETRY_ATTR, 1);
checkAttribute($request, "PLUTON_KEEPAFFINITY_ATTR", PLUTON_KEEPAFFINITY_ATTR, 1);
#!/usr/local/bin/php
<?php 
function abortme($why, $excode)
{
    print "Context1 failed: {$why}\n";
    exit($excode);
}
$client = new PlutonClient('context');
$request = new PlutonClientRequest();
$client->initialize();
if (!$request->setContext("random", 23)) {
    abortme("Context set of innocuous name failed", 1);
}
if ($request->setContext("pluton.haha", 24)) {
    abortme("Context set of protected namespace succeeded", 2);
}
$request->reset();
$request->setContext("echo.sleepMS", "3300");
$res = $client->addRequest("system.echo.0.raw", $request);
print "AddRequest = {$res}\n";
if (!$res) {
    $em1 = $request->getFaultText();
    $em2 = $client->getFault();
    abortme("addRequest Failed with {$em1}:{$em2}", 3);
}
$st = time();
$res = $client->executeAndWaitAll();
print "E&WAll = {$res}\n";
$et = time();
print "Time diffs st={$st} et={$et}\n";
if ($st + 2 > $et) {
Exemple #6
0
print "Long={$flong}\n";
if (strlen($flong) == 0) {
    print "Long message should not be zero length\n";
    exit(3);
}
if (strlen($fshort) == strlen($flong)) {
    print "Hmm expected short message to be shorter than long message\n";
    exit(4);
}
$client->initialize();
$client->reset();
if ($client->hasFault()) {
    print "client has fault after reset - bad\n";
    exit(5);
}
$request = new PlutonClientRequest();
$request->setRequestData("Some data");
$client->addRequest('system.echo.0.raw', $request);
if ($request->inProgress()) {
    print "Request is in progress - good\n";
} else {
    print "Request is NOT in progress - bad\n";
    exit(6);
}
$client->reset();
if ($request->inProgress()) {
    print "Request is in progress - bad\n";
    exit(7);
} else {
    print "Request is NOT in progress - good\n";
}
Exemple #7
0
#!/usr/local/bin/php
<?php 
$expected = "I expect this to be echo'd out";
$client = new PlutonClient('simple');
$client->initialize();
$request = new PlutonClientRequest();
$request->setRequestData($expected);
$request->setClientHandle(23);
$client->addRequest('system.echo.0.raw', $request);
$client->executeAndWaitSent();
if ($request->inProgress()) {
    print "Request is in progress\n";
} else {
    print "Request is NOT in progress\n";
}
$res = $client->executeAndWaitAny();
print "executeAndWaitAny returned {$res}\n";
$res = $request->getClientHandle();
if ($res != 23) {
    print "Expected return client handle of 23 rather than {$res}\n";
    exit(2);
}
print "getClientHandle returned {$res}\n";
$responseData = null;
$request->getResponseData($responseData);
if ($responseData != $expected) {
    print "Client test failed\n  expected: {$expected}\n  received: {$responseData}\n";
    exit(3);
}
print "Calling reset\n";
$request->reset();