Start adding alternate message streamers. Make algorithms less bad.

This commit is contained in:
Piv
2020-02-26 21:58:42 +10:30
parent 6e00106d90
commit 136c96a926
3 changed files with 69 additions and 13 deletions

View File

@@ -0,0 +1,46 @@
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_bytes):
pass
def send_message_topic(self, topic, message_bytes):
pass
class BluetoothStreamer(Streamer):
def __init__(self):
pass
def send_message(self, message_bytes):
pass