2017 © Pedro Peláez
 

library protocol_json_stream

image

jiaozi/protocol_json_stream

  • Wednesday, July 18, 2018
  • by gaohuia
  • Repository
  • 1 Watchers
  • 1 Stars
  • 2 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 3 Versions
  • 0 % Grown

The README.md

protocol_json_stream

A protocol for json message transfer over stream., (*1)

It's designed for working with workerman. The following piece of code shows you how to make a message server;, (*2)

<?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., (*3)

<?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!, (*4)

The Versions

18/07 2018

dev-master

9999999-dev

  Sources   Download

The Requires

 

The Development Requires

by zhenxing

18/07 2018

v1.0.1

1.0.1.0

  Sources   Download

The Requires

 

The Development Requires

by zhenxing

18/07 2018

v1.0.0

1.0.0.0

  Sources   Download

The Requires

 

The Development Requires

by zhenxing