forked from walkor/live-camera
-
Notifications
You must be signed in to change notification settings - Fork 0
/
start_worker.php
43 lines (39 loc) · 1.19 KB
/
start_worker.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
<?php
/**
* This file is part of workerman.
*
* Licensed under The MIT License
* For full copyright and license information, please see the MIT-LICENSE.txt
* Redistributions of files must retain the above copyright notice.
*
* @author walkor<walkor@workerman.net>
* @copyright walkor<walkor@workerman.net>
* @link http://www.workerman.net/
* @license http://www.opensource.org/licenses/mit-license.php MIT License
*/
use \Workerman\Worker;
use \Workerman\Protocols\Websocket;
require_once __DIR__ . '/vendor/autoload.php';
$recv_worker = new Worker('Websocket://0.0.0.0:8080');
$recv_worker->onWorkerStart = function($recv_worker)
{
$send_worker = new Worker('Websocket://0.0.0.0:8008');
$send_worker->onMessage = function($connection, $data)
{
};
$recv_worker->sendWorker = $send_worker;
$send_worker->listen();
};
$recv_worker->onMessage = function($connection, $data)use($recv_worker)
{
foreach($recv_worker->sendWorker->connections as $send_connection)
{
//$send_connection->websocketType = "\x82";
$send_connection->send($data);
}
};
// 如果不是在根目录启动,则运行runAll方法
if(!defined('GLOBAL_START'))
{
Worker::runAll();
}