-
Notifications
You must be signed in to change notification settings - Fork 8
/
EasySwooleEvent.php
39 lines (34 loc) · 1.19 KB
/
EasySwooleEvent.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
<?php
namespace EasySwoole\EasySwoole;
use App\Websocket\Events;
use EasySwoole\EasySwoole\AbstractInterface\Event;
use EasySwoole\EasySwoole\Swoole\EventRegister;
use WonderGame\EsUtility\Common\Classes\FdManager;
use WonderGame\EsUtility\EventInitialize;
use WonderGame\EsUtility\EventMainServerCreate;
class EasySwooleEvent implements Event
{
public static function initialize()
{
$EventInitialize = new EventInitialize([
'httpTracker' => 'Joyboo-admin',
'httpTrackerConfig' => ['redis-name' => 'default']
]);
$EventInitialize->run();
// 注册SwooleTable(WebSocket连接符管理)
FdManager::getInstance()->register();
}
public static function mainServerCreate(EventRegister $register)
{
$consumers = [];
if (is_file($file = EASYSWOOLE_ROOT . '/App/CustomProcess/config.php')) {
$consumers = include $file;
}
$EventMainServerCreate = new EventMainServerCreate([
'EventRegister' => $register,
'webSocketEvents' => Events::class,
'consumerJobs' => is_array($consumers) ? $consumers : false,
]);
$EventMainServerCreate->run();
}
}