class Connection(object): """ A remote native-protocol connection. """ def __init__(self, server, socket): self.server = server self.socket = socket self.queue = Queue() self.input_thread = InputThread(socket, self.message_received) self.output_thread = OutputThread(socket, self.queue.get) def start(self): self.input_thread.start() self.output_thread.start() def message_received(self, message): if message is None: self.server.post_event({"event": "disconnected", "connection": self}) self.server.remote_message_received(self, message) def send(self, message): self.queue.put(message)
def __init__(self, server, socket): self.server = server self.socket = socket self.queue = Queue() self.input_thread = InputThread(socket, self.message_received) self.output_thread = OutputThread(socket, self.queue.get)