hugvey/test_pub.py
2019-01-16 09:00:49 +01:00

28 lines
617 B
Python

import zmq
import random
import sys
import time
import hugvey.communication
import coloredlogs, logging
coloredlogs.install(
level=logging.DEBUG
)
port = "5555"
if len(sys.argv) > 1:
port = sys.argv[1]
int(port)
context = zmq.Context()
socket = context.socket(zmq.PUB)
socket.connect("tcp://127.0.0.1:%s" % port)
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)