Beispiel #1
0
function init()
{
    $ips = \avs\IPs::get();
    // ip1, ip2, ip3, ...
    // ip1 -> ip2
    // ip2 -> ip3
    // ip3 -> ip1
    // do we have enough
    // attention: $ips contains our local IP
    if (count($ips) > 1) {
        for ($index = 0, $count = count($ips); $index < $count - 1; $index++) {
            $ip = $ips[$index];
            $neighborIp = $ips[$index + 1];
            // sende 0->1, 1->2, 2-3, 3-4 etc
            inform($ip, $neighborIp);
        }
        // 1st  / last
        $count = count($ips);
        $myIp = $ips[0];
        $lastIp = $ips[$count - 1];
        // sende last->0
        inform($lastIp, $myIp);
    } else {
        echo "too less known IPs";
    }
}
Beispiel #2
0
/**
 * Created by PhpStorm.
 * User: JanKa
 * Date: 29.08.2015
 * Time: 16:27
 */
include_once '../src/Logger.php';
include_once '../src/IPs.php';
include_once '../src/HttpGet.php';
// $ips = \avs\IPs::get();
$ips = array();
if (isset($_GET['ips'])) {
    $ips = \avs\IPs::update($_GET['ips']);
} else {
    $ips = \avs\IPs::get();
}
$allItems = array();
if (null != $ips && count($ips) > 0) {
    foreach ($ips as $ip) {
        if (null != $ip && strlen($ip) > 0) {
            $url = "http://" . $ip . "/AVS-U1/web/getLoggerJSON.php";
            // echo("requesting: " . $url);
            $remoteJSON = \avs\HttpGet::get($url);
            // echo("remoteJSON: " . $remoteJSON);
            if (strlen($remoteJSON) > 0) {
                $remoteItems = \avs\Item::fromJSON($remoteJSON);
                $allItems = array_merge($allItems, $remoteItems);
            }
        }
    }