ngatngay / swoole-socket.io
There is no license information available for the latest version (dev-master) of this package.
:rainbow: Socket.io Server implementation for Swoole
dev-master
2024-11-03 02:23 UTC
Requires
- php: >=8.3
- ext-json: *
- ext-swoole: >=5.0.0
Requires (Dev)
- phpunit/phpunit: ^7.5
- swoole/ide-helper: @dev
This package is auto-updated.
Last update: 2024-11-03 02:25:14 UTC
README
🌈 Socket.io Server implementation for Swoole
Code Contributors
Thank you.[Contribute].
Server
Server Config
$config = new SocketIO\Engine\Server\ConfigPayload(); $config // server worker_num ->setWorkerNum(2) // server daemonize ->setDaemonize(0);
Examples
$io = new SocketIO\Server(9501, $config, function(SocketIO\Server $io) { $io->on('connection', function (SocketIO\Server $socket) { $socket->on('new message', function (SocketIO\Server $socket) { $socket->broadcast('new message', $socket->getMessage()); }); $socket->on('new user', function (SocketIO\Server $socket) { $socket->broadcast('login', $socket->getMessage()); }); $socket->on('disconnect', function (SocketIO\Server $socket) { $socket->broadcast('user left', $socket->getMessage()); }); }); }); $io->start();