Add simple and complete client to PHP

This commit is contained in:
AnthorNet 2015-05-04 10:24:52 +02:00
parent 81dd04eae3
commit 3875a01a2e
6 changed files with 56 additions and 3 deletions

View File

@ -1,3 +0,0 @@
"php.exe" -f %~dp0\Client.php
pause

View File

@ -0,0 +1,3 @@
"php.exe" -f %~dp0\Client_Complete.php
pause

View File

@ -0,0 +1,3 @@
"php.exe" -f %~dp0\Client_Simple.php
pause

View File

@ -0,0 +1,49 @@
<?php
/**
* Configuration
*/
$relayEDDN = 'tcp://eddn-relay.elite-markets.net:9500';
$timeoutEDDN = 600000;
/**
* START
*/
$context = new ZMQContext();
$subscriber = $context->getSocket(ZMQ::SOCKET_SUB);
$subscriber->setSockOpt(ZMQ::SOCKOPT_SUBSCRIBE, "");
$subscriber->setSockOpt(ZMQ::SOCKOPT_RCVTIMEO, $timeoutEDDN);
while (true)
{
try
{
$subscriber->connect($relayEDDN);
while (true)
{
$message = $subscriber->recv();
if ($message === false)
{
$subscriber->disconnect($relayEDDN);
break;
}
$message = zlib_decode($message);
$json = json_decode($message, true);
fwrite(STDOUT, $json . PHP_EOL);
}
}
catch (ZMQSocketException $e)
{
fwrite(STDOUT, 'ZMQSocketException: ' . $e . PHP_EOL);
sleep(10);
}
}
// Exit correctly
exit(0);

View File

@ -10,6 +10,7 @@ __relayEDDN = 'tcp://eddn-relay.elite-markets.net:9500'
__timeoutEDDN = 600000
"""
" Start
"""