onPush()函数在使用symfony2中Symfony/Websocket bundle的吉尼斯世界纪录中的ZeroMQ从控制器推送后未被命中
Config.ymlonPush()函数在使用symfony2中Symfony/Websocket bundle的吉尼斯世界纪录中的ZeroMQ从控制器推送后未被命中,symfony,websocket,zeromq,Symfony,Websocket,Zeromq,Config.yml gos_web_socket: topics: - @app.real_time.subscribe - @app.real_time.push server: port: 8000 #The port the socket server will listen on host: localhost #The host ip to bind to router:
gos_web_socket:
topics:
- @app.real_time.subscribe
- @app.real_time.push
server:
port: 8000 #The port the socket server will listen on
host: localhost #The host ip to bind to
router:
resources:
- @AppBundle/Resources/config/pubsub/routing.yml
client:
firewall: main #can be an array of firewalls
session_handler: @session.handler.pdo
pushers:
zmq:
default: true
host: 127.0.0.1
port: 8888
persistent: true
protocol: tcp
real_time_push:
channel: all/user
handler:
callback: 'app.real_time.push' #related to the getName() of your topic
app.real_time.subscribe:
class: AppBundle\RealTime\Subscribe
arguments: [ @gos_web_socket.websocket.client_manipulator ]
app.real_time.push:
class: AppBundle\RealTime\Push
arguments: [ @gos_web_socket.websocket.client_manipulator ]
pubsub/routing.yml
gos_web_socket:
topics:
- @app.real_time.subscribe
- @app.real_time.push
server:
port: 8000 #The port the socket server will listen on
host: localhost #The host ip to bind to
router:
resources:
- @AppBundle/Resources/config/pubsub/routing.yml
client:
firewall: main #can be an array of firewalls
session_handler: @session.handler.pdo
pushers:
zmq:
default: true
host: 127.0.0.1
port: 8888
persistent: true
protocol: tcp
real_time_push:
channel: all/user
handler:
callback: 'app.real_time.push' #related to the getName() of your topic
app.real_time.subscribe:
class: AppBundle\RealTime\Subscribe
arguments: [ @gos_web_socket.websocket.client_manipulator ]
app.real_time.push:
class: AppBundle\RealTime\Push
arguments: [ @gos_web_socket.websocket.client_manipulator ]
services.yml
gos_web_socket:
topics:
- @app.real_time.subscribe
- @app.real_time.push
server:
port: 8000 #The port the socket server will listen on
host: localhost #The host ip to bind to
router:
resources:
- @AppBundle/Resources/config/pubsub/routing.yml
client:
firewall: main #can be an array of firewalls
session_handler: @session.handler.pdo
pushers:
zmq:
default: true
host: 127.0.0.1
port: 8888
persistent: true
protocol: tcp
real_time_push:
channel: all/user
handler:
callback: 'app.real_time.push' #related to the getName() of your topic
app.real_time.subscribe:
class: AppBundle\RealTime\Subscribe
arguments: [ @gos_web_socket.websocket.client_manipulator ]
app.real_time.push:
class: AppBundle\RealTime\Push
arguments: [ @gos_web_socket.websocket.client_manipulator ]
当客户端订阅此主题时,以下函数将被命中。我可以在控制台中看到文本
Subscribe()上的Subscribe类:Subscribe.php
public function onSubscribe(ConnectionInterface $connection, Topic $topic, WampRequest $request)
{
var_dump("This user is subscribed");
}
public function onPush(Topic $topic, WampRequest $request, $data, $provider)
{
var_dump("Helloooooooooooooooooo0000000000");
}
但是当从控制器通过zmq推送时,onPush()函数从未被击中。我已经在Push.php中实现了TopicInterdace和PushableTopicInterface
Push类onPush():Push.php
public function onSubscribe(ConnectionInterface $connection, Topic $topic, WampRequest $request)
{
var_dump("This user is subscribed");
}
public function onPush(Topic $topic, WampRequest $request, $data, $provider)
{
var_dump("Helloooooooooooooooooo0000000000");
}
请任何人告诉我哪里做错了。提前谢谢。这是控制器
$pusher = $this->container->get('gos_web_socket.zmq.pusher');
//push(data, route_name, route_arguments)
$pusher->push(['my_data' => 'data'], 'real_time_push', ['username' => 'sujit']);