2017 © Pedro Peláez
 

library polytalk

Protocol to communicate between languages.

image

polytalk/polytalk

Protocol to communicate between languages.

  • Friday, November 30, 2012
  • by andruu
  • Repository
  • 1 Watchers
  • 7 Stars
  • 3 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 1 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

Polytalk

Polytalk is a simple protocol which allows communication between different languages via TCP., (*1)

Polytalk currently supports PHP, Node.js and Ruby., (*2)

Protocol

The protocol is a simple language agnostic JSON object containing the class, method and arguments. It will then return an response as either a string or JSON object., (*3)

Key           Value
class         The class to call the method on. Namespaced classes require the :: separator.
method        The method you want to call.
arguments     The arguments to inject into the method in key value pairs.

Installation

The recommended way to install Polytalk is through composer., (*4)

"require": {
  "polytalk/polytalk": "dev-master"
}

Server Example

Be sure that any classes you want to be exposed by the server to the client are included/required from the server., (*5)

$server = new Polytalk\Server(['port' => 9090]);
$server->run(function ($connection, $request) use ($server) {
  $response = $server->call($request);
  $server->push($connection, $response);
});

Client Example

$client  = new Polytalk\Client(['port' => 9090]);

$request = [
    'class' => 'Model::Order',
    'method' => 'findBySize',
    'arguments' => [
        'size' => 'small',
        'limit' => 3
    ]
];

// Return response
$response = $client->call($request);
var_dump($response);

// Callback
$first_order = $client->call($request, function ($response) {
  return $response[0];
});
var_dump($first_order);

License

MIT, see LICENSE., (*6)

The Versions

30/11 2012

dev-master

9999999-dev

Protocol to communicate between languages.

  Sources   Download

MIT

The Requires

 

by Avatar andruu

socket protocol polytalk