ali-eltaweel / socket-worker
There is no license information available for the latest version (1.3.1) of this package.
Socket Worker
1.3.1
2025-11-24 05:43 UTC
Requires
- php: ^8.1
- ali-eltaweel/codecs: ^1.2
- ali-eltaweel/computed-properties: ^1.0.0
- ali-eltaweel/dto: ^1.3.0
- ali-eltaweel/files: ^1.1
- ali-eltaweel/logger: ^2.0
- ali-eltaweel/serial-codec: ^1.1.0
README
Socket Worker
Installation
composer require ali-eltaweel/socket-worker
Basic Usage
Worker
$worker = new SocketWorker\SocketWorker( socketPath: 'path/to/socket/file', statusFilePath: 'path/to/socket/status/file', commandsCodec: new class implements Codecs\ICodec { /**/ }, commandHandler: function(SocketWorker\Commands\SocketCommand $command): SocketWorker\Commands\SocketResponse { // ... return new SocketWorker\Commands\SocketResponse(status: true, data: []); } ); while ($worker->status === SocketWorker\SocketWorkerStatus::Ready) { $worker->accept(); }
Dispatcher
$worker = new SocketWorker\SocketWorkerInterface( socketPath: 'path/to/socket/file', statusFilePath: 'path/to/socket/status/file', commandsCodec: new class implements Codecs\ICodec { /**/ } ); /** * @var SocketWorker\Commands\SocketResponse $response */ $response = $worker->execute(new SocketWorker\Commands\SocketCommand('cmd', arguments: []));