Skip to content

Commit ab7b1ba

Browse files
committed
config & doc update
1 parent d9b17ae commit ab7b1ba

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+22
-4541
lines changed

composer.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@
1717
"ext-swoole": "^4.0.0"
1818
},
1919
"require-dev": {
20-
"phpunit/phpunit": "^7.2"
20+
"phpunit/phpunit": "^8.2",
21+
"swoole/ide-helper": "@dev"
2122
},
2223
"autoload": {
2324
"files": [ "src/Helpers/magics.php" ],

src/Core/Client.php

+3-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* ------------------------------------------------------------------------------------
77
*
88
* @author lanlin
9-
* @change 2018/06/30
9+
* @change 2019/07/26
1010
*/
1111
class Client
1212
{
@@ -25,6 +25,7 @@ class Client
2525
'package_eof' => '', // \u262F
2626
'server_port' => null,
2727
'server_host' => '/var/run/swoole.sock',
28+
'server_type' => SWOOLE_SOCK_UNIX_STREAM,
2829
'debug_file' => APPPATH . 'logs/swoole_debug.log',
2930
];
3031

@@ -50,7 +51,7 @@ public static function send(array $data)
5051
/**
5152
* @property array $stamsel
5253
*/
53-
$client = new \Swoole\Client(SWOOLE_UNIX_STREAM, $mode);
54+
$client = new \Swoole\Client(self::$config['server_type'], $mode);
5455

5556
// dynamic custom data
5657
$client->CiSwooleData = $data;

src/Core/Server.php

+8-3
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* ------------------------------------------------------------------------------------
77
*
88
* @author lanlin
9-
* @change 2018/09/25
9+
* @change 2019/07/26
1010
*/
1111
class Server
1212
{
@@ -22,6 +22,7 @@ class Server
2222
[
2323
'server_port' => null,
2424
'server_host' => '/var/run/swoole.sock',
25+
'server_type' => SWOOLE_SOCK_UNIX_STREAM,
2526
'debug_file' => APPPATH . 'logs/swoole_debug.log',
2627
];
2728

@@ -59,7 +60,7 @@ public static function start()
5960
self::$cfgs['server_host'],
6061
self::$cfgs['server_port'],
6162
SWOOLE_PROCESS,
62-
SWOOLE_UNIX_STREAM
63+
self::$cfgs['server_type']
6364
);
6465

6566
// init config
@@ -263,8 +264,12 @@ private static function initConfig()
263264
self::$cfgs['debug_file'] = $config['debug_file'];
264265
self::$cfgs['server_host'] = $config['server_host'];
265266
self::$cfgs['server_port'] = $config['server_port'];
267+
self::$cfgs['server_type'] = $config['server_type'];
266268

267-
unset($config['debug_file'], $config['server_host'], $config['server_port']);
269+
unset(
270+
$config['debug_file'], $config['server_host'],
271+
$config['server_port'], $config['server_type'],
272+
);
268273

269274
self::$config = array_merge($config, self::$config);
270275
}

src/Helpers/swoole.php

+9-2
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,21 @@
88
| For custom configuration, you can copy this swoole.php to
99
| the application/config folder.
1010
|
11+
| Example for tcp:
12+
| $swoole['server_type'] = SWOOLE_SOCK_TCP;
13+
| $swoole['server_host'] = '127.0.0.1';
14+
| $swoole['server_port'] = 9501;
15+
|
1116
| Warning:
1217
| Do not change any configuration, unless you know what it is!
1318
|
1419
| For more detail document, view this link below
1520
| @link https://www.swoole.co.uk/docs/modules/swoole-server-doc
21+
| @link https://wiki.swoole.com/wiki/page/476.html
1622
*/
17-
$swoole['server_host'] = '127.0.0.1';
18-
$swoole['server_port'] = 9501;
23+
$swoole['server_type'] = SWOOLE_SOCK_UNIX_STREAM;
24+
$swoole['server_host'] = '/var/run/swoole.sock';
25+
$swoole['server_port'] = null;
1926

2027

2128
/*

src/doc/classes.php

-146
This file was deleted.

src/doc/constants.php

-61
This file was deleted.

0 commit comments

Comments
 (0)