-
-
Save jkarneges/d3179119cdb412da9daa to your computer and use it in GitHub Desktop.
listen for pushpin subscription changes
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
import sys | |
import zmq | |
if len(sys.argv) < 2: | |
print 'usage: %s [pub_spec]' % sys.argv[0] | |
sys.exit(1) | |
spec = sys.argv[1] | |
zmq_context = zmq.Context.instance() | |
sock = zmq_context.socket(zmq.XPUB) | |
sock.rcvhwm = 0 # ensure the subscription list is never truncated | |
sock.immediate = 1 # clear subscriptions on disconnect | |
sock.connect(spec) | |
while True: | |
m = sock.recv() | |
mtype = m[0] | |
topic = m[1:] | |
if mtype == '\x01': | |
print 'SUB %s' % topic | |
elif mtype == '\x00': | |
print 'UNSUB %s' % topic |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
run like this: