hugvey/test_pub.py

29 lines
617 B
Python
Raw Permalink Normal View History

2019-01-15 22:34:59 +00:00
import zmq
import random
import sys
import time
import hugvey.communication
2019-01-16 08:00:49 +00:00
import coloredlogs, logging
coloredlogs.install(
level=logging.DEBUG
)
2019-01-15 22:34:59 +00:00
port = "5555"
if len(sys.argv) > 1:
port = sys.argv[1]
int(port)
context = zmq.Context()
socket = context.socket(zmq.PUB)
2019-01-16 08:00:49 +00:00
socket.connect("tcp://127.0.0.1:%s" % port)
2019-01-15 22:34:59 +00:00
while True:
# topic = random.randrange(9999,10005)
# topic = "hv" + str(random.randrange(1,3))
messagedata = str(time.time())
# print ("{} {}".format(topic, messagedata))
hugvey.communication.zmqSend(socket, random.randrange(1,3), messagedata)
time.sleep(1)