concerto/comms

Library for Inter-Process Communications using Unix domain sockets.

This package's canonical repository appears to be gone and the package has been frozen as a result.

Maintainers

Details

github.com/usebeagle/comms

Installs: 647

Dependents: 2

Suggesters: 0

Security: 0

Stars: 28

Watchers: 0

Forks: 2

Type:concerto-component

v0.8 2014-08-15 22:50 UTC

This package is not auto-updated.

Last update: 2020-08-07 18:31:41 UTC


README

Library for Inter-Process Communications using Unix domain sockets.

Build Status

Install

The recommended way to install Comms is through composer.

{
    "require": {
        "concerto/comms": "0.*"
    }
}

Usage

Server

use Concerto\Comms\Server;
use React\EventLoop\Factory;

$loop = Factory::create();
$comms = new Server($loop, 'unix://' . __DIR__ . '/test.ipc');

$comms->on('join', function() {
	echo "Client joined.\n";
});

$comms->on('part', function() {
	echo "Client exited.\n";
});

$comms->on('message', function($message) use ($comms) {
	echo "Client said: $message\n";

	$comms->send('...');
});

$comms->listen();
$loop->run();

Client

use Concerto\Comms\Client;
use React\EventLoop\Factory;

$loop = Factory::create();
$comms = new Client($loop, 'unix://' . __DIR__ . '/test.ipc');

$comms->on('join', function() {
	echo "Server joined.\n";
});

$comms->on('part', function() {
	echo "Server exited.\n";
	exit;
});

$comms->on('message', function($data) {
	echo "Server said: $data\n";
});

$comms->send('...');

$comms->connect();
$loop->run();