Coder Social home page Coder Social logo

msgpackphp's Introduction

MsgPackPhp

This package tries to leverage the power of Message Pack and msgpack.php

Mainly this uses https://github.com/msgpack-rpc/msgpack-rpc-php while updating the underlying code & upgrading to the above mentioned msgpack.php package.

There are 3 possible use cases for this repository due to it's server & client perspective

  1. Client (my main use case)
$client = new Client('localhost', '1985');

$messages =  $client->call("SyncJob", $job, $payload);

echo array_pop($messages);

aside from the obvious host and port arguments for the Client class, let's see the arguments for the call function:

  • first argument is a string naming the function to be called on the server side (see tests/server.php)
  • the call method is a variadic function, hence the following arguments are concatenated to an array on the server
  1. Server (not thoroughly tested)
try {
    $server = new Server('1985', new App());
    echo 'Server is listening on port 1985...';
    $server->recv();
} catch (Exception $e) {
    echo $e->getMessage();
}

see tests/server.php for full example

  1. Client and Server

this would be a good use case if you use multiple services or you need back and forth communication

*if you need this between the same 2 services maybe best to take into account switching to http/2 where

  $backChannel = new BackChannel();

  $client = new Client('localhost', '1986', $backChannel);    
  $messages =  $client->call("SyncJob", $job, $payload);    
  echo array_pop($messages);
  
  try {
      $server = new Server('1985', new App(), $backChannel);
      echo 'Server is listening on port 1985...';
      $server->recv();
  } catch (Exception $e) {
      echo $e->getMessage();
  }

yes, in this case as it was the case for the original package, it makes sense to use the BackChannel combined

Other options

The package provides necessary interfaces & Traits in order to have your own Server or Client enhancements without the need to modify the base classes whom one can mainly use as references rather than implementations as it makes only for the most basic use case.

msgpackphp's People

Contributors

decebal avatar

Watchers

 avatar  avatar  avatar

msgpackphp's Issues

Copy Writing Proposal

Hello, i just checked your lovely project and i discovered you have some sections missing out like FAQ, about us, contact us and privacy policy. If you dont mind i will like to write that for you.
My email: [email protected]

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.