#!/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) {
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) { abortme("Context didn't caused echo to sleep - was it really set?", 3); }
#!/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 $expected = "I expect this to be echo'd out"; $client = new PlutonClient('execute'); $client->initialize(); $request10 = new PlutonClientRequest(); $request10->setRequestData($expected); $request10->setClientHandle(10); $request2 = new PlutonClientRequest(); $request2->setRequestData($expected); $request2->setClientHandle(2); $request3 = new PlutonClientRequest(); $request3->setRequestData($expected); $request3->setClientHandle(3); $client->addRequest('system.echo.0.raw', $request10); $client->addRequest('system.echo.0.raw', $request2); $client->addRequest('system.echo.0.raw', $request3); $res = $client->executeAndWaitOne($request2); print "executeAndWaitOne returned {$res}\n"; if ($res != 1) { print "E&WOne failed. Expected return of 1 rather than {$res}\n"; exit(2); } print "executeAndWaitOne = {$res} = ok\n"; $res = $client->executeAndWaitAny(); if ($res != 10 && $res != 3) { print "E&WAny failed. Expected return of 10 or 3 rather than {$res}\n"; exit(2); } print "executeAndWaitAny returned 3 or 10 - good\n"; print "executeAndWaitAny first = ok\n";