webman如何进行长链接推送?

不败少龙

在控制器里面直接推送 就跟结合tp框架那样直接调用 是需要自己去实现还是可以用gatewayworker去做?
解决方案:
直接用webman/push 插件,超级好用
https://www.workerman.net/doc/webman/plugin/push.html

3821 5 1
5个评论

latin

自己会实现就自己实现,不想自己实现或者不会就用gatewayworker呗

不败少龙

哦哦! 之前在控制器里面用过gatewayworker里面直接用,webman没有试过怎么用

  • 暂无评论
xamarin

https://wenda.workerman.net/question/6460 数据库加载项从webman中独立出来,单独初始化,可以和webnan一个时间启动.在webman 路径可以随便调用数据库,不需要初始化和在composer 里做额外的工作.webman 昨天的问题已完美解决,有类似的问题欢迎兄弟们交流.谢谢兄弟们.

  • 暂无评论
不败少龙

自定义命令行:

<?php

namespace app\command;

use GatewayWorker\BusinessWorker;
use GatewayWorker\Gateway;
use GatewayWorker\Register;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Workerman\Worker;
use Symfony\Component\Console\Input\InputArgument;

class GatewayCommand extends \Symfony\Component\Console\Command\Command
{

    protected static $defaultName = 'config:gateway';
    protected static $defaultDescription = 'gateway服务配置';

    protected function configure()
    {
        $this
        // 命令的名称 ("php console_command" 后面的部分)
        //->setName('model:create')
        // 运行 "php console_command list" 时的简短描述
        ->setDescription('Create new model')
        // 运行命令时使用 "--help" 选项时的完整命令描述
        ->setHelp('This command allow you to create models...')
        // 配置一个参数
        ->addArgument('name', InputArgument::REQUIRED, 'what\'s model you want to create ?');
    }

    protected function execute(InputInterface $input, OutputInterface $output)
    {
        global $argv;
//        $argv[2] = 'start';
        $argv[3] = '-d';

        $output->writeln('gateway服务配置信息如下:');

        $this->startGateWay();
        $this->startBusinessWorker();
        $this->startRegister();
        Worker::runAll();
//        $table = new Table($output);
//        $table->setHeaders($headers);
//        $table->setRows($row);
//        $table->render();
        return self::SUCCESS;
    }

    private function startBusinessWorker()
    {
        $worker = new BusinessWorker();
        $worker->name = 'BusinessWorker';
        $worker->count = 1;
        $worker->registerAddress = '127.0.0.1:1237';
        $worker->eventHandler = app_path() . "/service/Events.php";
    }

    private function startGateWay()
    {
        $gateway = new Gateway("websocket://0.0.0.0:2347");
        $gateway->name = 'Gateway';
        $gateway->count = 4;
        $gateway->lanIp = '127.0.0.1';
        $gateway->startPort = 40001;
        $gateway->pingInterval = 30;
        $gateway->pingNotResponseLimit = 0;
        $gateway->pingData = '{"type":"ping"}';
        $gateway->registerAddress = '127.0.0.1:1237';//正式 1237  测试 1236

    }

    private function startRegister()
    {
        new Register('text://0.0.0.0:1237');
    }
}
  • 暂无评论
walkor

直接用webman/push 插件,超级好用
https://www.workerman.net/doc/webman/plugin/push.html

年代过于久远,无法发表评论

不败少龙

8994
积分
0
获赞数
0
粉丝数
2018-08-17 加入
🔝