src.dualinventive.com/jjacobs/dinetrpcll-sniffer/libdipp/common/ditest-php/rpc/PublishSocket.php

37 lines
748 B
PHP

<?php
require_once(__DIR__ . '/RpcCommon.php');
if (!isset($g_zmqcontext)) {
$g_zmqcontext = new ZMQContext();
}
class PublishSocket extends RpcCommon {
private $__socket;
function __construct(&$test, $uri) {
parent::__construct($test);
global $g_zmqcontext;
$this->__test = $test;
$this->__socket = $g_zmqcontext->getSocket(ZMQ::SOCKET_PUB);
$this->__socket->bind($uri);
}
/**
* ..
*/
function send($data, $result = null) {
if (is_string($data)) {
$ret = $this->__socket->send($data);
} elseif (is_array($data)) {
$ret = $this->__socket->send(json_encode($data));
} else {
$this->__test->failure("RPC message is not a valid reply");
var_dump($data);
}
$this->_test->equal($this->__socket, $ret);
}
}