I have two protocols, one a WebSocket server the other a ZeroMQ pull socket. I want to forward things received my ZMQ to the WebSocket. Is this possible?
class WebSocketProtocol(WebSocketServerProtocol):
def onMessage(self, msg, binary):
print "Received: ", msg, binary
self.sendMessage(msg, binary)
class MyProto(ZmqPullConnection):
def onPull(self, message):
print "Recevied: ", message
# How to I call sendMessage(message) from here?
if __name__ == '__main__':
zf = ZmqFactory()
e = ZmqEndpoint("bind", "tcp://127.0.0.1:5500")
s = MyProto(zf, e)
factory_ws = WebSocketServerFactory("ws://127.0.0.1:9500/echo", debug = False)
factory_ws.protocol = WebSocketProtocol
listenWS(factory_ws)
reactor.run()