Exemplo n.º 1
0
ini_set('max_execution_time', '999999999999999999999999999999999999999999999999');
// change to the proper directory
chdir("./RtmpClient");
// the rtmp client library
require_once "RtmpClient.class.php";
// go back
chdir("../");
date_default_timezone_set("America/Chicago");
// For all time() uses, otherwise it goes mad.
//var_dump($argv); // get cmd line args, $argv[0] is always the script full file name.
$sends = array();
$recvs = array();
$running = true;
$client = new RtmpClient();
$client->connect($rtmp, "tinyconf", $port, array($roomname, $autoop, "show", "tinychat", $BotUsername));
runClient();
function runClient()
{
    global $running, $sends, $recvs, $client, $safeusers;
    while ($running) {
        // Critical events, check before bot receive/send! Better to avoid these.
        if (false) {
            $time = time();
            if ($time - $safeusers['time'] > 20) {
                $safeusers['time'] = 0;
                // not finished meh... supposed to ban anyone not in safelist,
                // but only one every while loop!
            }
        }
        // proccess recvs
        foreach ($recvs as $i => $recv) {
Exemplo n.º 2
0
    $settings = getSettings();
    $client = Client::getInstance($settings);
    $type = 'echo';
    $data = array('foo' => 'bar', 'baz' => 9001);
    $resultId = $client->putRequest($type, $data);
    Common::$lg->addDebug("Client put request {$resultId} on AMQ");
    $result = $client->getResult($resultId);
    Common::$lg->addDebug("Client got data for {$resultId}");
    if ($result->{'foo'} == $data['foo'] && $result->{'baz'} == $data['baz']) {
        exit(0);
    } else {
        echo "Client received wrong data for {$resultId}";
        exit(1);
    }
}
setupLogger();
if (isset($argv[1])) {
    $mode = $argv[1];
    $forever = isset($argv[2]) && $argv[2] == 'forever';
    if ($mode == MODE_CLIENT) {
        runClient($forever);
    } else {
        if ($mode == MODE_SERVER) {
            runServer($forever);
        } else {
            Common::$lg->addCritical("Unknown mode, select either 'client' or 'server'");
        }
    }
} else {
    Common::$lg->addCritical("No mode provided, provide either 'client' or 'server'");
}