jiaozi / protocol_json_stream
Installs: 25
Dependents: 1
Suggesters: 0
Security: 0
Stars: 1
Watchers: 1
Forks: 0
Open Issues: 0
pkg:composer/jiaozi/protocol_json_stream
Requires
- workerman/workerman: ^3.5
Requires (Dev)
- phpunit/phpunit: ^6.0
This package is not auto-updated.
Last update: 2025-10-26 11:50:10 UTC
README
A protocol for json message transfer over stream.
It's designed for working with workerman. The following piece of code shows you how to make a message server;
<?php use Workerman\Worker; require_once __DIR__ . "/vendor/autoload.php"; $woker = new Worker("tcp://127.0.0.1:1000"); // all you need to do is setting the protocol $woker->protocol = \pjs\protocols\JsonStreamProtocol::class; $woker->onMessage = function(Workerman\Connection\ConnectionInterface $conn, $data){ var_dump($data); }; Worker::runAll();
Now we can test against the server with a simple client; Here is the code.
<?php require_once __DIR__ . "/vendor/autoload.php"; // This package contains a simple client for message transfer. $client = new \pjs\ClientConnection("127.0.0.1:1000"); $client->connect(); $client->send(['hello' => 'hello']);
Have fun!