47 lines
1.1 KiB
Python
47 lines
1.1 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_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
|