Things Bus: Difference between revisions
From Pumping Station One
| Line 50: | Line 50: | ||
context = zmq.Context.instance() | context = zmq.Context.instance() | ||
# Create a zmq socket that will SUBscribe to door nodes. | # Create a zmq socket that will SUBscribe to door nodes. | ||
door_socket = context.socket(zmq.SUB) | door_socket = context.socket(zmq.SUB) | ||
| Line 56: | Line 56: | ||
door_socket.connect("tcp://backdoor.pumpingstationone.org:5556") | door_socket.connect("tcp://backdoor.pumpingstationone.org:5556") | ||
door_socket.setsockopt(zmq.SUBSCRIBE, b"door.state.unlock") | door_socket.setsockopt(zmq.SUBSCRIBE, b"door.state.unlock") | ||
# create a zmq socket that will PUSH data to our IRC actuator node. | # create a zmq socket that will PUSH data to our IRC actuator node. | ||
zirc_socket = context.socket(zmq.PUSH) | zirc_socket = context.socket(zmq.PUSH) | ||
zirc_socket.connect('tcp://sally.ad.pumpingstationone.org:5558') | zirc_socket.connect('tcp://sally.ad.pumpingstationone.org:5558') | ||
# Loop forever | # Loop forever | ||
while True: | while True: | ||
# Read messages from the doors | # Read messages from the doors | ||
topic, message = door_socket.recv_multipart() | topic, message = door_socket.recv_multipart() | ||
# Send the message to the irc channel | # Send the message to the irc channel | ||
zirc.send(message) | zirc.send(message) | ||