swoole / swoole-src

🚀 Coroutine-based concurrency library for PHP
https://www.swoole.com
Apache License 2.0
18.42k stars 3.16k forks source link

Best way to call Websocket server methods from other parts of application? #4159

Open julia-fix opened 3 years ago

julia-fix commented 3 years ago

Currently I'm trying to integrate Swoole websocket server to existing chat application for the purpose of sending notifications to online users. Can't find examples of calling Swoole\WebSocket\Server->push from php files other than one that starts the server. It is advised here https://stackoverflow.com/questions/49226659/swoole-with-rabbitmq to establish a server-side websocket connection to Swoole server to inform it about new event via a regular websocket message. Is it the only way to achieve websocket server from other server functions?

limingxinleo commented 3 years ago

Hi, You can take a look for this repo https://github.com/Gemini-D/chat-api

But I change to nsq from rabbitmq.

limingxinleo commented 3 years ago

https://github.com/gzydong/hyperf-chat

This repo use rabbitmq.