You've already forked qlg.tsgz.moe
addons
app_download_files
extend
hyhproject
mobile
oss
static
thinkphp
upload
vendor
5ini99
composer
oss-sdk
swoole
.github
benchmark
examples
include
src
tests
include
swoole_async
swoole_atomic
swoole_buffer
swoole_channel
swoole_client_async
swoole_client_coro
swoole_client_sync
swoole_coroutine
swoole_coroutine_channel
swoole_coroutine_util
swoole_event
swoole_function
swoole_http2_client
swoole_http2_client_coro
swoole_http_cilent_coro
swoole_http_client
swoole_http_server
swoole_https_client
swoole_lock
swoole_memory_pool
swoole_mysql
swoole_mysql_coro
swoole_process
swoole_redis
swoole_redis_coro
swoole_redis_server
swoole_serialize
swoole_server
addListener.phpt
addProcess.phpt
bigPipeMessage.phpt
big_udp_packet.phpt
bind.phpt
bug_11000_01.phpt
connections.phpt
dispatch_by_stream.phpt
dispatch_mode_1.phpt
dispatch_mode_3.phpt
eof_protocol.phpt
eof_server.phpt
exist.phpt
getClientInfo.phpt
getClientList.phpt
getLastError.phpt
getSocket.phpt
heartbeat.phpt
heartbeat_true.phpt
heartbeat_with_base.phpt
kill_task_worker_01.phpt
kill_task_worker_02.phpt
kill_worker_01.phpt
kill_worker_02.phpt
length_protocol.phpt
listen_fail.phpt
max_request.phpt
pid_file.phpt
protect.phpt
protect_false.phpt
reload.phpt
request_slowlog.phpt
sendMessage.phpt
sendMessage_02.phpt
sendfile.phpt
sendfile_02.phpt
sendfile_ssl.phpt
shutdown.phpt
slow_client.phpt
stats.phpt
stop.phpt
task.phpt
taskWaitMulti.phpt
task_callback.phpt
task_max_request.phpt
task_queue.phpt
taskwait.phpt
unsock_dgram.phpt
unsock_stream.phpt
use_process.phpt
swoole_server_port
swoole_socket_coro
swoole_table
swoole_timer
swoole_websocket_server
CONTRIBUTION
README.md
clean
coro_test.sh
new.sh
run-tests
start.sh
template.phpt
test-all-version.sh
test.sql
thirdparty
tools
travis
.gitignore
.gitmodules
.travis.yml
CMakeLists.txt
CREDITS
LICENSE
README.md
Version2.md
build.sh
clear.sh
config.m4
make.sh
package.xml
php7_wrapper.h
php_swoole.h
swoole.c
swoole_async.c
swoole_atomic.c
swoole_buffer.c
swoole_channel.c
swoole_channel_coro.cc
swoole_client.c
swoole_client_coro.c
swoole_config.h
swoole_coroutine.cc
swoole_coroutine.h
swoole_coroutine_util.c
swoole_event.c
swoole_http.h
swoole_http_client.c
swoole_http_client.h
swoole_http_client_coro.c
swoole_http_server.c
swoole_http_v2_client.c
swoole_http_v2_client.h
swoole_http_v2_client_coro.c
swoole_http_v2_server.c
swoole_lock.c
swoole_memory_pool.c
swoole_mmap.c
swoole_msgqueue.c
swoole_mysql.c
swoole_mysql.h
swoole_mysql_coro.c
swoole_postgresql_coro.c
swoole_postgresql_coro.h
swoole_process.c
swoole_process_pool.c
swoole_redis.c
swoole_redis_coro.c
swoole_redis_server.c
swoole_ringqueue.c
swoole_runtime.cc
swoole_serialize.c
swoole_serialize.h
swoole_server.c
swoole_server_port.c
swoole_socket_coro.c
swoole_table.c
swoole_timer.c
swoole_trace.c
swoole_websocket_server.c
wechat
.htaccess
autoload.php
wxtmp
.gitignore
.htaccess
.user.ini
404.html
H5B854518.wgt
admin.php
app-release.apk
app_download.html
cash.lock
demo.php
get_startup.php
get_version.php
get_version_new.php
index.html
index.php
qlg.tar.gz
reg.lock
robots.txt
84 lines
2.2 KiB
PHP
Executable File
84 lines
2.2 KiB
PHP
Executable File
--TEST--
|
|
swoole_server: task callback
|
|
--SKIPIF--
|
|
<?php require __DIR__ . '/../include/skipif.inc'; ?>
|
|
--INI--
|
|
assert.active=1
|
|
assert.warning=1
|
|
assert.bail=0
|
|
assert.quiet_eval=0
|
|
|
|
|
|
--FILE--
|
|
<?php
|
|
require_once __DIR__ . '/../include/bootstrap.php';
|
|
require_once __DIR__ . '/../include/swoole.inc';
|
|
$port = 9508;
|
|
|
|
$pm = new ProcessManager;
|
|
$pm->parentFunc = function ($pid) use ($port)
|
|
{
|
|
$cli = new swoole_client(SWOOLE_SOCK_TCP, SWOOLE_SOCK_SYNC);
|
|
$cli->set(['open_eof_check' => true, "package_eof" => "\r\n\r\n"]);
|
|
// $cli->set(['open_eof_split' => true, 'package_eof' => "\r\n\r\n"]);
|
|
$cli->connect("127.0.0.1", $port, 0.5) or die("ERROR");
|
|
|
|
$cli->send("task-01") or die("ERROR");
|
|
|
|
$res = json_decode(trim($cli->recv()), true);
|
|
assert($res['code'] == 0);
|
|
assert($res['message'] == 'hello world');
|
|
|
|
echo "SUCCESS\n";
|
|
|
|
$res = json_decode(trim($cli->recv()), true);
|
|
assert($res['code'] == 0);
|
|
assert($res['message'] == 'hello world');
|
|
echo "SUCCESS\n";
|
|
|
|
swoole_process::kill($pid);
|
|
};
|
|
|
|
$pm->childFunc = function () use ($pm, $port)
|
|
{
|
|
ini_set('swoole.display_errors', 'Off');
|
|
$serv = new swoole_server("127.0.0.1", $port);
|
|
$serv->set(array(
|
|
"worker_num" => 1,
|
|
'task_worker_num' => 2,
|
|
'log_file' => '/dev/null',
|
|
));
|
|
$serv->on("WorkerStart", function (\swoole_server $serv) use ($pm)
|
|
{
|
|
$pm->wakeup();
|
|
});
|
|
$serv->on('receive', function (swoole_server $serv, $fd, $rid, $data)
|
|
{
|
|
$serv->task(['type' => 'array', 'value' => $data], -1, function ($serv, $taskId, $data) use ($fd) {
|
|
$serv->send($fd, json_encode($data)."\r\n\r\n");
|
|
});
|
|
$serv->task(['type' => 'array', 'value' => $data, 'worker_id' => 0], 0, function ($serv, $taskId, $data) use ($fd) {
|
|
$serv->send($fd, json_encode($data)."\r\n\r\n");
|
|
});
|
|
});
|
|
|
|
$serv->on('task', function (swoole_server $serv, $task_id, $worker_id, $data)
|
|
{
|
|
return array("code" => 0, 'message' => 'hello world', 'sid' => uniqid());
|
|
});
|
|
|
|
$serv->on('finish', function (swoole_server $serv, $fd, $rid, $data)
|
|
{
|
|
|
|
});
|
|
$serv->start();
|
|
};
|
|
|
|
$pm->childFirst();
|
|
$pm->run();
|
|
?>
|
|
|
|
--EXPECT--
|
|
SUCCESS
|
|
SUCCESS
|