Created
December 31, 2013 11:27
-
-
Save fuzzysteve/8195524 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl | |
use warnings; | |
use strict; | |
use JSON; | |
use Compress::Zlib; | |
use List::Util qw[min max]; | |
use ZMQ::LibZMQ3; | |
use ZMQ::Constants qw/ZMQ_SUB ZMQ_SUBSCRIBE/; | |
$|=1; | |
my $context = zmq_init(1); | |
my $sock = zmq_socket($context, ZMQ_SUB); | |
zmq_connect($sock, "tcp://localhost:8050"); | |
#zmq_connect($sock, "tcp://ipv6.fuzzwork.co.uk:8050"); | |
zmq_setsockopt($sock,ZMQ_SUBSCRIBE, ""); | |
while (1) { | |
my $msg=zmq_recvmsg($sock); | |
last unless defined $msg; | |
my $json = uncompress(zmq_msg_data($msg)); | |
my $data = decode_json($json); | |
if ($data->{resultType} eq "orders") | |
{ | |
my $typeid=$data->{rowsets}[0]{typeID}; | |
print $data->{rowsets}[0]{regionID}." ".$typeid." ".$data->{rowsets}[0]{generatedAt}."\n"; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment