当前位置: 首页>>代码示例>>PHP>>正文


PHP broadcast函数代码示例

本文整理汇总了PHP中broadcast函数的典型用法代码示例。如果您正苦于以下问题:PHP broadcast函数的具体用法?PHP broadcast怎么用?PHP broadcast使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了broadcast函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: dparam

 function dparam($value)
 {
     $key = CutSegment('=', $value);
     $this->deviceDS['d_' . $key] = $value;
     $this->save();
     broadcast(array('type' => 'dparam_' . $key, 'device' => $this->deviceDS['d_key'], 'value' => $value));
 }
开发者ID:bangnaga,项目名称:HomeOverlord,代码行数:7,代码来源:H2HALDevice.php

示例2: process

function process($user, $msg)
{
    $action = unwrap($msg);
    $key = $action[0];
    say("\$ < " . $action);
    global $users;
    switch ($key) {
        case 'c':
            broadcast($user, $action);
            break;
        case 'm':
            broadcast($user, $action);
            break;
        case 'd':
            broadcast(null, $action);
            break;
        case 'g':
            send($user->socket, $user->id);
            break;
        case 'a':
            send($user->socket, count($users));
            break;
        case 'u':
            broadcast($user, $action);
            break;
        default:
            // if it is not a specific command then just relay it to all users
            say('Command "' . $action . '" not recognised');
            break;
    }
    //switch ($key)
}
开发者ID:harrynorthover,项目名称:sketchpad,代码行数:32,代码来源:server.php

示例3: broadcast_raw

function broadcast_raw($data, $id, $status = "missing")
{
    if (!isset($data['firstname']) || !isset($data['lastname'])) {
        return false;
    }
    $first = $data['firstname'];
    $last = $data['lastname'];
    if (isset($data['city'])) {
        $city = $data['city'];
    } else {
        $city = "";
    }
    if (isset($data['gender'])) {
        $gender = $data['gender'];
    } else {
        $gender = "";
    }
    if (isset($data['age'])) {
        $age = $data['age'];
    } else {
        $age = "";
    }
    if (isset($data['status'])) {
        $status = $data['status'];
    } else {
        $status = "";
    }
    $info = "http://www.haitianquake.com/person.php?id=" . $id;
    broadcast($first, $last, $city, $gender, $age, $info, "", "en", $status);
}
开发者ID:rmunro,项目名称:SMS-Turks,代码行数:30,代码来源:broadcast.php

示例4: handleBroadcast

function handleBroadcast($request, $response)
{
    $body = '';
    $request->on('data', function ($chunk) use(&$body) {
        $body .= $chunk;
    });
    $request->on('end', function () use(&$body) {
        broadcast($body);
    });
    $response->writeHead(202);
    $response->end();
}
开发者ID:phamthaithinh,项目名称:sse-broadcast-benchmark,代码行数:12,代码来源:server.php

示例5: header

header('Access-Control-Allow-Origin: *');
header('Access-Control-Allow-Headers: origin, x-requested-with, content-type, accept');
header('Access-Control-Allow-Methods: GET, POST, PUT, DELETE');
require_once __DIR__ . '/classes/connexion.php';
require_once __DIR__ . '/classes/checkAPI.php';
require_once __DIR__ . '/classes/PushMessage.php';
require_once __DIR__ . '/classes/Settings.php';
$page_level = 2;
if (isset($_REQUEST['api']) && checkAPI($_REQUEST['api'], $page_level)) {
    switch ($_SERVER['REQUEST_METHOD']) {
        case 'GET':
            echo json_encode(get());
            break;
        case 'POST':
            broadcast($_REQUEST);
            break;
        case 'PUT':
            update($_REQUEST);
            break;
    }
}
function broadcast($arr)
{
    $push = new PushMessage();
    if (isset($arr['secret'])) {
        $push->sendMessageAll('at_commands', 'geoi');
    } else {
        $push->sendMessageAll('at_commands', 'geo');
    }
    http_response_code(202);
开发者ID:nawrasg,项目名称:Atlantis,代码行数:30,代码来源:at_geo.php

示例6: callHandlers

 function callHandlers($handlers, $data)
 {
     foreach (array('', '_rev') as $addressType) {
         $reverseAction = $addressType == '_rev';
         $where = array();
         foreach ($handlers as $h) {
             $where[] = 'e_address' . $addressType . ' = ?';
         }
         foreach (o(db)->get('SELECT * FROM events
     WHERE (' . implode(' OR ', $where) . ')
     ORDER BY e_order ASC', $handlers) as $eds) {
             $GLOBALS['log'][] = 'event handler called: ' . $eds['e_address' . $addressType];
             broadcast(array('type' => 'eventHandled', 'address' => $eds['e_address' . $addressType]));
             $this->ignoreExecution = false;
             $emitterRoot = $data['device'];
             $emitterRoot = CutSegment(':', $emitterRoot);
             if ($emitterRoot != $data['device']) {
                 $emitterRootDS = getDeviceDS($emitterRoot);
             } else {
                 $emitterRootDS = $data['ds'];
             }
             $this->executeScript($eds['e_code'], array('emitter_id' => $data['device'], 'emitter_param' => $data['param'], 'emitter_value' => $data['value'], 'emitter_alias' => $emitterRootDS['d_alias'], 'emitter_root' => $emitterRoot, 'emitter_name' => first($emitterRootDS['d_name'], $emitterRootDS['d_id']), 'emitter' => $data['ds'], 'call' => $data, 'eventDS' => &$eds, 'reverseAction' => $reverseAction, 'event' => $eds['e_address' . $addressType]));
             if (!$this->ignoreExecution) {
                 o(db)->query('UPDATE events SET e_lastcalled = ' . time() . ' WHERE e_key = ' . $eds['e_key']);
             }
         }
     }
     return $this;
 }
开发者ID:bangnaga,项目名称:HomeOverlord,代码行数:29,代码来源:H2Event.php

示例7: Notification

     $notification = new Notification("Der Server wird in ca. 90 Minuten heruntergefahren.", "Serverbenachrichtigung", 0);
     $notification->setActionOpenPlugin("plg_serversettings");
     $notification->setMaxTimestamp(time() + 5400);
     $notification->setServerMessage();
     broadcast($notification);
     exec('sudo /var/www/sh/shutdown.sh 90');
     die('{"redirect":["' . $pluginManager->getPluginName() . '", "home", ""]}');
 } else {
     if ($loginManager->isAllowed(LoginManager::STOP_SERVER) && $command == "shutdown120") {
         require_once $pluginManager->getController('servertools');
         $logManager->addLog("Der Benutzer " . $loginManager->getUsername() . " hat einen Shutdown gestartet (2 Stunden).");
         $notification = new Notification("Der Server wird in ca. 2 Stunden heruntergefahren.", "Serverbenachrichtigung", 0);
         $notification->setActionOpenPlugin("plg_serversettings");
         $notification->setMaxTimestamp(time() + 7200);
         $notification->setServerMessage();
         broadcast($notification);
         exec('sudo /var/www/sh/shutdown.sh 120');
         die('{"redirect":["' . $pluginManager->getPluginName() . '", "home", ""]}');
     } else {
         if ($loginManager->isAllowed(LoginManager::STOP_SERVER) && $command == "shutdownstop") {
             exec('sudo /var/www/sh/shutdown.sh stop');
             $logManager->addLog("Der Benutzer " . $loginManager->getUsername() . " hat einen Shutdown gestoppt.");
             die('{"redirect":["' . $pluginManager->getPluginName() . '", "home", ""]}');
         } else {
             if ($loginManager->isAllowed(LoginManager::STOP_SERVER) && $command == "update") {
                 exec('sudo /var/www/sh/serverupdate.sh');
                 $logManager->addLog("Der Benutzer " . $loginManager->getUsername() . " hat ein Update gestartet.");
                 die('{"redirect":["' . $pluginManager->getPluginName() . '", "home", ""]}');
             }
         }
     }
开发者ID:michaelsoftware1997,项目名称:vision-server,代码行数:31,代码来源:home.php

示例8: disconnect

function disconnect($socket)
{
    global $sockets, $users;
    $found = null;
    $n = count($users);
    for ($i = 0; $i < $n; $i++) {
        if ($users[$i]->socket == $socket) {
            $found = $i;
            break;
        }
    }
    if (!is_null($found)) {
        $nick = $users[$found]->nick;
        $users[$found] = null;
        array_splice($users, $found, 1);
        broadcast("EXIT|" . $nick, $nick);
    }
    $index = array_search($socket, $sockets);
    socket_close($socket);
    console($socket . " DISCONNECTED!");
    if ($index >= 0) {
        array_splice($sockets, $index, 1);
    }
}
开发者ID:GeorgeNava,项目名称:phpwebsocketchat,代码行数:24,代码来源:chatserver.php

示例9: define

<?php

//begin bus1
define('REG_ID_FILE', 'regID-bus.data');
define('API_KEY', '<your API key>');
define('MTA_KEY', '<your MTA key>');
$url = "http://api.prod.obanyc.com/api/siri/stop-monitoring.json?key=" . MTA_KEY . "&MonitoringRef=400516";
if (!empty($_REQUEST['regid'])) {
    store_regID($_REQUEST['regid']);
} else {
    broadcast();
}
function get_regIDs()
{
    if (file_exists(REG_ID_FILE)) {
        return unserialize(file_get_contents(REG_ID_FILE));
    }
    return array();
}
function store_regID($regID)
{
    $a = get_regIDs();
    $a[$regID] = 1;
    file_put_contents(REG_ID_FILE, serialize($a));
}
//end
function broadcast()
{
    $num_sent = 0;
    for ($n = 0; $n < 20;) {
        $regIDs = '';
开发者ID:ghosta3,项目名称:programming_chrome_apps,代码行数:31,代码来源:gcmv2-bus.php

示例10: disconnect

function disconnect($socket)
{
    global $sockets, $users;
    $found = null;
    $n = count($users);
    for ($i = 0; $i < $n; $i++) {
        if ($users[$i]->socket == $socket) {
            $found = $i;
            broadcast($users[$i], json_encode(array('type' => 'DISCONNECT', 'slot' => $users[$i]->id)));
            $query = sprintf("SELECT * FROM `boards` WHERE wb_id = '%s' AND usr_id = '%s'", mysql_real_escape_string($users[$i]->whiteboard_id), mysql_real_escape_string($users[$i]->id));
            $result = mysql_query($query);
            while ($row = mysql_fetch_assoc($result)) {
                $obj = json_decode($row['obj'], true);
                if ($obj['selected'] == true) {
                    $obj['selected'] = false;
                    $query = sprintf("REPLACE INTO `boards` (`wb_id`, `obj_id`, `usr_id`, `obj`, `index`) VALUES ('%s', '%s', '%s', '%s', '%s');", mysql_real_escape_string($users[$i]->whiteboard_id), mysql_real_escape_string($obj['id']), mysql_real_escape_string($users[$i]->id), mysql_real_escape_string(json_encode($obj)), mysql_real_escape_string($obj['index']));
                    $r = mysql_query($query);
                    if (!$r) {
                        say('Error inserting: ' . mysql_error());
                    }
                }
            }
            break;
        }
    }
    if (!is_null($found)) {
        array_splice($users, $found, 1);
    }
    $index = array_search($socket, $sockets);
    socket_close($socket);
    console($socket . " DISCONNECTED!");
    if ($index >= 0) {
        array_splice($sockets, $index, 1);
    }
}
开发者ID:nrc-cnrc,项目名称:HTML5-whiteboard,代码行数:35,代码来源:server.php

示例11: actionUrl

    <td><a 
      style="<?php 
    echo 'client/' . $_SERVER['REMOTE_ADDR'] == $client['nv_key'] ? 'font-weight:bold' : '';
    ?>
"
      href="<?php 
    echo actionUrl('client_settings', 'devices', array('id' => $client['nv_key']));
    ?>
"><?php 
    echo $client['nv_key'];
    ?>
</a></td>
    <td><?php 
    echo ageToString($client['nv_lastupdate']);
    ?>
</td>
  </tr><?php 
}
?>
</table>

<hr/>
<input type="button" value="reload"
  onclick="document.location.href='<?php 
echo actionUrl('clients', 'devices', array('do' => 'reload'));
?>
';"/> all screens
<?php 
if ($_REQUEST['do'] == 'reload') {
    broadcast(array('type' => 'reload'));
}
开发者ID:bangnaga,项目名称:HomeOverlord,代码行数:31,代码来源:devices.clients.php

示例12: output

     } else {
         if (strtolower($line) == "/quit") {
             output($i, "Bye!\n");
             broadcast("{$usernames[$i]} has logged off.", $i);
             $close[$i] = true;
         } elseif (strtolower($line) == "/shutdown") {
             $shutting_down = true;
             broadcast("Shutting down. See you later.\n");
         } elseif (strtolower($line) == "/who") {
             output($i, "Current users:\n");
             foreach ($usernames as $u) {
                 output($i, "{$u}\n");
             }
         } else {
             $msg = '[' . $usernames[$i] . ']: ' . $line . "\n";
             broadcast($msg, $i);
             output($i, ">>> {$line}\n");
         }
     }
 }
 foreach ($writefds as $wfd) {
     $i = (int) $wfd;
     if (!empty($output[$i])) {
         $w = socket_write($wfd, $output[$i]);
         if ($w == strlen($output[$i])) {
             $output[$i] = "";
             if (isset($close[$i])) {
                 close($i);
             }
         } else {
             $output[$i] = substr($output[$i], $w);
开发者ID:bozhink,项目名称:Code-Chunks,代码行数:31,代码来源:chat_server.php

示例13: on_connect

function on_connect($client_index)
{
    global $clients;
    global $connections;
    $connection_index = connection_index($client_index, True);
    if ($connection_index === False) {
        $addr = "";
        socket_getpeername($clients[$client_index], $addr);
        $connection = array();
        $connection["client_index"] = $client_index;
        $connection["addr"] = $addr;
        $connection["connect_timestamp"] = microtime(True);
        $connection["ident_prefix"] = "";
        $connection["authenticated"] = False;
        $connections[] = $connection;
        broadcast("*** CLIENT CONNECTED: {$addr}");
    } else {
        do_reply($client_index, "*** CLIENT CONNECT ERROR: CONNECTION EXISTS ALREADY");
    }
}
开发者ID:cmn32480,项目名称:exec-irc-bot,代码行数:20,代码来源:irciv_serv_lib.php

示例14: var_export

                    # code...
                    break;
            }
        } else {
            var_export($frame->data);
            $ws->push($frame->fd, jsonResult('error', FORBID_CODE, '非法参数请求!'));
        }
    }
});
$ws->on('close', function ($ws, $fd) {
    $usr = get_usr_by_fd($ws, $fd);
    if (!empty($usr)) {
        $ws->table_user->del($usr['name']);
        $data = array('username' => $usr['name'], 'avatar' => $usr['avatar']);
        //广播离线提示
        broadcast($ws, $fd, 'offline', SUCCESS_CODE, "{$usr['name']} 已经下线", $data);
        logger("{$usr['name']} 已经下线");
    }
});
$ws->start();
/**
 * json格式化返回结果
 * @param $action
 * @param int $code
 * @param string $info
 * @param string $data
 * @return string
 */
function jsonResult($action, $code = SUCCESS_CODE, $info = '', $data = '')
{
    $ret = array('action' => $action, 'data' => $data, 'info' => $info, 'code' => $code);
开发者ID:findbrick,项目名称:bubble,代码行数:31,代码来源:bubble.php

示例15: broadcastUpdate

 function broadcastUpdate()
 {
     foreach ($this->radiatorSettings as $k => $v) {
         broadcast(array_merge(array('type' => 'radiator', 'id' => $k), $v));
     }
 }
开发者ID:bangnaga,项目名称:HomeOverlord,代码行数:6,代码来源:radiator.controller.php


注:本文中的broadcast函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。