Skip to content

Basttyy/socket.io-swoole-server

 
 

Repository files navigation

socket.io-swoole-server

🌈 Socket.io Server implementation for Swoole

Build Status

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();

About

🌈 Socket.io Server implementation for Swoole

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • PHP 97.6%
  • Dockerfile 1.9%
  • Shell 0.5%