Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allows send WebSocket message to any fd in current server, even the worker process does not hold the fd #418

Merged
merged 12 commits into from Aug 19, 2019

Conversation

limingxinleo
Copy link
Member

fix #403

<?php

declare(strict_types=1);

namespace App\Controller;

use Hyperf\HttpServer\Annotation\AutoController;
use Hyperf\WebSocketServer\Sender;

/**
 * @AutoController
 */
class HttpController extends Controller
{
    public function index()
    {
        $fd = $this->request->input('fd');

        $sender = $this-container->get(Sender::class);

        $sender->push((int) $fd, 'Hello Hyperf.');

        return $this->response->success();
    }
}

@limingxinleo
Copy link
Member Author

@huangzhhui 都改过了

{
$this->server = $server;
return $this->container->get(ServerFactory::class)->getServer()->getServer();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里应该改成获取 Swoole\Server

@huangzhhui huangzhhui changed the title Fixed fd does not found when server::push. Allows send WebSocket message to any fd in current server, even the worker process does not hold the fd Aug 19, 2019
@limingxinleo limingxinleo merged commit 3f1d518 into hyperf:master Aug 19, 2019
@limingxinleo limingxinleo deleted the ws-server branch August 19, 2019 08:56
@smallsha123
Copy link

文档上咋没有

@huangzhhui
Copy link
Member

文档上咋没有

这里并没有改变 WebSocket 本身的使用方式,我们只是加强了它的容错性,文档上也可以写一下我们会这么做

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[FEATURE] 是否可以实现 一个 websocket 主动推送消息的功能
3 participants