Exemplo n.º 1
0
<?php

namespace Subspace\Test;

require_once __DIR__ . '/common.php';
$subspace = InitSubspace("http://127.0.0.1/test/test-receive.php");
$result = $subspace->send(['purpose' => 'greeting', 'name' => 'John Doe']);
if ($result === FALSE) {
    die("Failed to connect. (" . $subspace->transceiver()->info('url') . "; HTTP Code " . $subspace->transceiver()->info('http_code') . ")\n\n");
} else {
    echo "Receiver responded: " . $result['greeting'] . "\n\n";
}
Exemplo n.º 2
0
<?php

namespace Subspace\Test;

require_once __DIR__ . '/common.php';
$subspace = InitSubspace(NULL);
$request = $subspace->read();
switch ($request['purpose']) {
    case 'greeting':
        $name = $request['name'];
        $subspace->send(['greeting', "Hello there, {$name}!"]);
        break;
    default:
        $subspace->send(['greeting', "Hello there, nameless friend!"]);
}