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

HTTP控制器中无法调用 websocket 发送消息api #1495

Open
aikonchem opened this issue Feb 16, 2023 · 0 comments
Open

HTTP控制器中无法调用 websocket 发送消息api #1495

aikonchem opened this issue Feb 16, 2023 · 0 comments

Comments

@aikonchem
Copy link

Q A
Bug report? no
Feature request? yes
Swoft version 2.1
Swoole version 5.1
PHP version 8.1
Runtime environment Mac

Describe the bug
在http控制器调用
/** @var \Swoole\WebSocket\Server $server /
$server->push(1, 'hello, welcome! :)');
提示Undefined variable $server
bean配置文件
'wsServer' => [
'class' => WebSocketServer::class,
'port' => 18308,
'listener' => [
//'rpc' => bean('rpcServer'),
'tcp' => bean('tcpServer'),
],
'on' => [
// Enable http handle
SwooleEvent::REQUEST => bean(RequestListener::class),
// Enable task must add task and finish event
SwooleEvent::TASK => bean(TaskListener::class),
SwooleEvent::FINISH => bean(FinishListener::class)
],
//'debug' => 1,
'debug' => env('SWOFT_DEBUG', 0),
/
@see WebSocketServer::$setting */
'setting' => [
'task_worker_num' => 6,
'task_enable_coroutine' => true,
'worker_num' => 6,
'log_file' => alias('@runtime/swoole.log'),
// 'open_websocket_close_frame' => true,
],

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

No branches or pull requests

3 participants