-
Notifications
You must be signed in to change notification settings - Fork 0
/
start.php
executable file
·38 lines (34 loc) · 1.25 KB
/
start.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
<?php
use \Workerman\Worker;
use \Workerman\WebServer;
use \GatewayWorker\Gateway;
use \GatewayWorker\BusinessWorker;
use \Workerman\Autoloader;
require_once __DIR__ . '/Workerman/Autoloader.php';
require_once __DIR__ . '/controller.php';
Autoloader::setRootPath(__DIR__);
$GLOBALS['CU'] = new controller();
Worker::$daemonize = true;
addLog('Booting...');
$bWorker = new BusinessWorker();
$bWorker->name = 'UselessWorker';
$bWorker->count = 1;
$workerInst = new Worker("tcp://127.0.0.1:4000");
$workerInst->name = 'CoreSystemController';
$workerInst->count = 1;
$workerInst->onMessage = function($connection, $message){
addLog('Worker:Received message!');
$messageData = json_decode($message, true);
$newInstruction = new instructions($messageData['time'], $messageData['id'], $messageData['aid'], $messageData['code'], $messageData['amount'], $messageData['price'], $messageData['type'], NULL, $messageData['msec']);
addLog('Worker:Prepare to process the instruction!');
$cu = $GLOBALS['CU'];
$cu->process($newInstruction);
};
$gateway = new Gateway("tcp://127.0.0.1:1935");
$gateway->name = 'CoreSystemGateway';
$gateway->count = 4;
$gateway->lanIp = '127.0.0.1';
$gateway->startPort = 2000;
$gateway->pingInterval = 10;
$gateway->pingData = '';
Worker::runAll();