-
Notifications
You must be signed in to change notification settings - Fork 0
/
example.php
57 lines (52 loc) · 1.61 KB
/
example.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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
<?php
require_once './vendor/autoload.php';
$config = [
'timezone' => 'Asia/Shanghai',
'tick_interval_timer' => 30, //秒
'websocket' => [
'enable' => true,
'host' => '0.0.0.0',
'port' => '9000',
'type' => SWOOLE_SOCK_TCP,
'setting' => [
'daemonize' => false,
'task_worker_num' => 1,
],
'handler' => \swoole_websocket_and_tcp_and_udp_test\webscoket::class,
],
'http' => [
'enable' => true,
'host' => '0.0.0.0',
'port' => '9001',
'type' => SWOOLE_SOCK_TCP,
'setting' => [],
'handler' => \swoole_websocket_and_tcp_and_udp_test\http::class,
],
'tcp' => [
'enable' => true,
'host' => '0.0.0.0',
'port' => '9002',
'type' => SWOOLE_SOCK_TCP,
'setting' => [
'open_eof_check' => true,
'package_eof' => "\r\n",
'dispatch_mode' => 2,
'heartbeat_check_interval' => 30,
'heartbeat_idle_time' => 60,
],
'handler' => \swoole_websocket_and_tcp_and_udp_test\tcp::class,
],
'udp' => [
'enable' => true,
'host' => '0.0.0.0',
'port' => '9003',
'type' => SWOOLE_SOCK_UDP,
'setting' => [
'open_eof_check' => true,
'package_eof' => "\r\n",
],
'handler' => '',
],
];
$server = new \swoole_websocket_and_tcp_and_udp\Server($config);
$server->run();