mirror of
https://github.com/EDCD/EDDN.git
synced 2026-10-25 01:06:24 +03:00
Add python 3.4 example
This commit is contained in:
1 parent
58f47222f3
commit
f9376c59ea
11 files changed
+296
-10
No files matched your search
@@ -0,0 +1,50 @@
|
||||
import zlib
|
||||
import zmq
|
||||
import simplejson
|
||||
import sys
|
||||
|
||||
"""
|
||||
" Configuration
|
||||
"""
|
||||
__relayEDDN = 'tcp://eddn-relay.elite-markets.net:9500'
|
||||
__timeoutEDDN = 600000
|
||||
|
||||
|
||||
|
||||
"""
|
||||
" Start
|
||||
"""
|
||||
def main():
|
||||
context = zmq.Context()
|
||||
subscriber = context.socket(zmq.SUB)
|
||||
|
||||
subscriber.setsockopt(zmq.SUBSCRIBE, "")
|
||||
subscriber.setsockopt(zmq.RCVTIMEO, __timeoutEDDN)
|
||||
|
||||
while True:
|
||||
try:
|
||||
subscriber.connect(__relayEDDN)
|
||||
|
||||
while True:
|
||||
__message = subscriber.recv()
|
||||
|
||||
if __message == False:
|
||||
subscriber.disconnect(__relayEDDN)
|
||||
break
|
||||
|
||||
__message = zlib.decompress(__message)
|
||||
__json = simplejson.loads(__message)
|
||||
|
||||
|
||||
print __json
|
||||
sys.stdout.flush()
|
||||
|
||||
except zmq.ZMQError, e:
|
||||
print 'ZMQSocketException: ' + str(e)
|
||||
sys.stdout.flush()
|
||||
time.sleep(10)
|
||||
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
Reference in new issue
Block a user