pzverr / websocket
Simple websocket server on php, based on morozovsk/websocket
This package's canonical repository appears to be gone and the package has been frozen as a result.
dev-master
2017-11-29 15:02 UTC
Requires
- php: >=5.3.0
- ext-mbstring: *
This package is not auto-updated.
Last update: 2023-06-28 13:26:32 UTC
README
Fork of morozovsk/websocket.
Add Custom options in Daemon Class.
Installation
{ "require": { "pzverr/websocket": "dev-master", } }
Symfony2 Example
AppBundle\Console\Command\WebSocketServerCommand.php
class WebSocketServerCommand extends ContainerAwareCommand { ... protected function execute(InputInterface $input, OutputInterface $output) { $em = $this->getContainer()->get('doctrine')->getManager(); $servers = [ 'default' => [ 'class' => 'AppBundle\WebSocket\DefaultDaemonHandler', 'pid' => '/tmp/websocket_default.pid', 'websocket' => 'tcp://localhost:5001', 'options' => [ 'em' => $em, ] ] ]; $action = $input->getArgument('action'); $server = $input->getArgument('server'); $WebSocketServer = new Server($servers[$server]); call_user_func(array($WebSocketServer, $action)); } }
AppBundle\Services\DefaultDaemonHandler.php
use pzverr\websocket\Daemon; ... class DefaultDaemonHandler extends Daemon { protected function onOpen($connectionId, $info) { $entity = $this->em->getRepository('FooBundle:Entity')->find(1); //etc } } ...