think-swoole的onReceive事件没有接收到值

浏览:1715 发布日期:2018/09/20 分类:求助交流 关键字: swoole
<?php
namespace app\http;

use think\swoole\Server;

class Swoole extends Server
{
        protected $host = '0.0.0.0';
        protected $port = 9501;
        protected $serverType = 'socket';
        protected $mode = SWOOLE_PROCESS;
        protected $sockType = SWOOLE_SOCK_TCP;
        protected $option = [
                'worker_num'=> 4,
                'max_request' => 10000,
                'daemonize'     => false,
                'backlog'       => 128
        ];

        public function onMessage($server, $frame) {
                echo "receive from {$frame->fd}:{$frame->data},opcode:{$frame->opcode},fin:{$frame->finish}\n";
                $server->push($frame->fd, "this is server");
        }

        public function onReceive($server, $fd, $from_id, $data)
        {
                $server->send($fd, 'Swoole: '.$data);
        }

        public function onClose($ser, $fd) {
                echo "client {$fd} closed\n";
        }
}
按照手册自定义了swoole服务类,也配置了'swoole_class' => 'app\http\Swoole',启动服务后能连但onReceive没有接收到数据也没有返回信息
最佳答案
评论( 相关
后面还有条评论,点击查看>>