Skip to content

Commit

Permalink
Introduce messenger interface to v2.x.x
Browse files Browse the repository at this point in the history
  • Loading branch information
WyriHaximus committed Mar 24, 2021
1 parent 0aff095 commit 5ef2c9e
Show file tree
Hide file tree
Showing 2 changed files with 75 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Messenger.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
use WyriHaximus\React\ChildProcess\Messenger\Messages\Message;
use WyriHaximus\React\ChildProcess\Messenger\Messages\Rpc;

class Messenger extends EventEmitter
class Messenger extends EventEmitter implements MessengerInterface
{
const INTERVAL = 0.1;
const TERMINATE_RPC = 'wyrihaximus.react.child-process.messenger.terminate';
Expand Down
74 changes: 74 additions & 0 deletions src/MessengerInterface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
<?php

namespace WyriHaximus\React\ChildProcess\Messenger;

use WyriHaximus\React\ChildProcess\Messenger\Messages\ActionableMessageInterface;
use WyriHaximus\React\ChildProcess\Messenger\Messages\Error;
use WyriHaximus\React\ChildProcess\Messenger\Messages\LineInterface;
use WyriHaximus\React\ChildProcess\Messenger\Messages\Message;
use WyriHaximus\React\ChildProcess\Messenger\Messages\Rpc;

interface MessengerInterface
{
/**
* @param string $target
* @param callable $listener
*/
public function registerRpc($target, callable $listener);

/**
* @param string $target
*/
public function deregisterRpc($target);

/**
* @param string $target
* @return bool
*/
public function hasRpc($target);

/**
* @param $target
* @param $payload
* @return React\Promise\PromiseInterface
*/
public function callRpc($target, $payload);

/**
* @param Message $message
*/
public function message(Message $message);

/**
* @param Error $error
*/
public function error(Error $error);

/**
* @param string $uniqid
* @return OutstandingCall
*/
public function getOutstandingCall($uniqid);

/**
* @param Rpc $rpc
* @return \React\Promise\Promise
*/
public function rpc(Rpc $rpc);

/**
* @param ActionableMessageInterface $line
* @return LineInterface
*/
public function createLine(ActionableMessageInterface $line);

/**
* @return \React\Promise\Promise
*/
public function softTerminate();

/**
* @param string $line
*/
public function write($line);
}

0 comments on commit 5ef2c9e

Please sign in to comment.