コード例 #1
0
        echo "  0\n";
    }, null, 0, array('strict' => true));
    $queue->push($handler);
    $handler = new Event\Handler(null, function ($e) {
        echo "  A\n";
    }, null, 1.5, array('strict' => true));
    $queue->push($handler);
} catch (\Exception $e) {
    $success = false;
}
if ($success) {
    echo "Success!\n";
} else {
    echo "Failure...\n";
}
echo "    Fire! -> \n";
$success = true;
$publisher = $event = null;
try {
    $publisher = new Patterns\Publisher();
    $publisher->attachListener($queue);
    $event = new Event\GenericEvent(null, null, null, null);
    $publisher->setState($event);
} catch (\Exception $e) {
    $success = false;
}
if ($success) {
    echo "Success!\n\n";
} else {
    echo "Failure...\n\n";
}
コード例 #2
0
ファイル: Actor.php プロジェクト: asherwunk/primus2
    $publisher = new Patterns\Publisher();
    echo $publisher ? "Success!\n" : "Failure...\n";
    echo "    Instantiate Actor ( filter, handler, publisher ) -> ";
    $actor = new Event\Actor($filter, $handler, $publisher);
    echo $actor ? "Success!\n" : "Failure...\n";
} catch (\Exception $e) {
    $success = false;
}
if (!$success) {
    echo "EXCEPTION RAISED\n";
}
echo "\nBasic Operations -- \n\n";
$success = true;
try {
    echo "    Fire Event1 -> ";
    $publisher->setState($event1);
} catch (\Exception $e) {
    $success = false;
}
if (!$success) {
    echo "EXCEPTION RAISED\n";
}
$success = true;
try {
    echo "\n    Fire Event2 -> ";
    $publisher->setState($event2);
} catch (\Exception $e) {
    $success = false;
}
if (!$success) {
    echo "EXCEPTION RAISED\n";
コード例 #3
0
ファイル: Conduit.php プロジェクト: asherwunk/primus2
echo "        Fire Publisher 1 (Event1) -- ";
$success = true;
try {
    $publisher1->setState($event1);
} catch (\Exception $e) {
    $success = false;
}
if ($success) {
    echo "Success!\n\n";
} else {
    echo "Failure...\n\n";
}
echo "        Fire Publisher 2 (Event2) -- ";
$success = true;
try {
    $publisher2->setState($event2);
} catch (\Exception $e) {
    $success = false;
}
if ($success) {
    echo "Success!\n\n";
} else {
    echo "Failure...\n\n";
}
echo "        Remove Publisher 2 from Conduit 3 -> ";
$success = true;
try {
    $conduit3->removePublisher($publisher2);
} catch (\Exception $e) {
    $success = false;
}