Files
picar/Messaging/message_factory.py
2020-02-26 23:00:06 +10:30

52 lines
1.2 KiB
Python

import zmq
class MessageFactory():
def getZmqPubSubStreamer(self, topic):
'''
Not thread-safe. Always get this inside the thread/process where you intend
to use it.
'''
return ZmqPubSubStreamer(topic)
class Streamer():
def send_message(self, message_bytes):
raise NotImplementedError
def send_message_topic(self, topic, message_bytes):
raise NotImplementedError
class ZmqPubSubStreamer(Streamer):
'''
Not thread-safe. Always get this inside the thread/process where you intend
to use it.
'''
def __init__(self, port):
# Should create the socket here always, since zmq is not thread safe.
# Hopefully whoever uses this is not stupid enough to create it then
# pass it into a thread.
pass
def send_message(self, message):
'''
Args
----
message: A message type that has the serialise() method.
'''
pass
def send_message_topic(self, topic, message):
pass
class BluetoothStreamer(Streamer):
def __init__(self):
pass
def send_message(self, message_bytes):
pass