I have setup websocket in my project and follow Installation Instructions as you mention.
your demo is working nice but, when i tried to implement it on my project, I'm getting
rpc handler acme.rpc not exists, only [ ] are available
error.
I'm attaching code which i did.
config.yml
`gos_web_socket:
server:
port: 8081 #The port the socket server will listen on
host: 192.168.1.32 #The host ip to bind to
router:
resources:
pubsub_routing.ymlacme_rpc: channel: api/{method} handler: callback: 'acme.rpc' #related to the getName() or your RPC service requirements: method: pattern: "[a-z_]+"
AcmeRpc.php
`<?php
/**
Created by PhpStorm.
User: sotsys-161
Date: 2/7/16
Time: 12:26 PM
*/
namespace Slideshow\SocketBundle\RPC;
use Ratchet\ConnectionInterface;
use Gos\Bundle\WebSocketBundle\RPC\RpcInterface;
use Gos\Bundle\WebSocketBundle\Router\WampRequest;
class AcmeRpc implements RpcInterface
{
/*
* Adds the params together
* Note: $conn isnt used here, but contains the connection of the person making this request.
* @param ConnectionInterface $connection
* @param WampRequest $request
* @param array $params
* @return int
/
public function sum(ConnectionInterface $connection, WampRequest $request, $params)
{
return array("result" => array_sum($params));
}
/**
* Name of RPC, use for pubsub router (see step3)
*
* @return string
*/
public function getName()
{
return 'acme.rpc';
}
I have setup websocket in my project and follow Installation Instructions as you mention. your demo is working nice but, when i tried to implement it on my project, I'm getting
I'm attaching code which i did. config.yml `gos_web_socket: server: port: 8081 #The port the socket server will listen on host: 192.168.1.32 #The host ip to bind to router: resources:
pubsub_routing.yml
acme_rpc: channel: api/{method} handler: callback: 'acme.rpc' #related to the getName() or your RPC service requirements: method: pattern: "[a-z_]+"
AcmeRpc.php `<?php /**
namespace Slideshow\SocketBundle\RPC;
use Ratchet\ConnectionInterface; use Gos\Bundle\WebSocketBundle\RPC\RpcInterface; use Gos\Bundle\WebSocketBundle\Router\WampRequest;
class AcmeRpc implements RpcInterface { /* * Adds the params together * Note: $conn isnt used here, but contains the connection of the person making this request. * @param ConnectionInterface $connection * @param WampRequest $request * @param array $params * @return int / public function sum(ConnectionInterface $connection, WampRequest $request, $params) { return array("result" => array_sum($params)); }
}`