teddy / websockets
Helps to use websockets
Installs: 21
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 1
Forks: 0
Open Issues: 0
pkg:composer/teddy/websockets
Requires
- cboden/ratchet: ^0.3.3
- nette/di: ~2.3.0
- textalk/websocket: ^1.2
This package is not auto-updated.
Last update: 2025-10-04 02:54:57 UTC
README
Extension, helps with using WebSockets
Usage
composer require teddy/websockets
Copy websockets.js file, override the Controller
, add /bin/server.php
Run /bin/server.php
use Ratchet\Server\IoServer; use Ratchet\Http\HttpServer; use Ratchet\WebSocket\WsServer; require dirname(__DIR__) . '/vendor/autoload.php'; $rootDir = __DIR__ . '/..'; $params = [ 'wwwDir' => $rootDir . '/www', 'appDir' => $rootDir . '/app', 'tempDir' => $rootDir . '/temp', 'testMode' => TRUE ]; $configurator = (new Nette\Configurator($params)) ->addConfig(__DIR__ . '/config.neon') ->setDebugMode(TRUE); $configurator->createRobotLoader() ->addDirectory(__DIR__ . '/../app') ->register(); $container = $configurator->createContainer(); $server = IoServer::factory( new HttpServer( new WsServer( new \Teddy\WebSockets\Controller($container) // you should override this class ) ), 8080 ); $server->run();
It is neccessary to create subdomain wss.domain.tld
, becase SSL won't work otherwise.
http://grezcz.tumblr.com/post/143320629816/rozchozen%C3%AD-ratchetu-na-ssl (check whether it won't break HTTP o_O)