def data_received(self, data): data = self._rest + data (msgs, rest) = tincanchat.parse_recvd_data(data) self._rest = rest for msg in msgs: msg = msg.decode('utf-8') msg = '{}: {}'.format(self.addr, msg) print(msg) msg = tincanchat.prep_msg(msg) for client in clients: client.transport.write(msg)
def data_received(self, data): """ handle data as its received, broadcast complete message to all other clients """ data = self._rest + data (msgs, rest) = tincanchat.parse_recvd_data(data) self._rest = rest for msg in msgs: msg = msg.decode('utf-8') msg = '{}: {}'.format(self.addr, msg) print(msg) msg = tincanchat.prep_msg(msg) for client in clients: client.transport.write(msg)
def data_received(self, data): """ Handle data as it's received. Broadcast complete messages to all other clients """ data = self._rest + data parts = data.split(b'\0') msgs = parts[:-1] rest = parts[-1] self._rest = rest for msg in msgs: msg = msg.decode('utf-8') msg = '{}: {}'.format(self.addr, msg) print(msg) msg = tincanchat.prep_msg(msg) self.transport.write(msg)
def data_received(self, data): """ Handle data as it's received. Broadcast complete messages to all other clients """ data = self._rest + data (msgs, rest) = tincanchat.parse_recvd_data(data) self._rest = rest for msg in msgs: msg = '{}: {}'.format(self.addr, msg) print(msg) msg = tincanchat.prep_msg(msg) for client in clients: client.transport.write(msg) # <-- non-blocking
def data_received(self, data): """ Handle data as it's received. Broadcast complete messages to all other clients """ data = self._rest + data (msgs, rest) = tincanchat.parse_recvd_data(data) self._rest = rest for msg in msgs: msg = '{}: {}'.format(self.addr, msg) print(msg) msg = tincanchat.prep_msg(msg) for client in clients: client.transport.write(msg) # <-- non-blocking
def broadcast_msg(msg): '''Add message to all connected clients' queues''' data = tincanchat.prep_msg(msg) for client in clients.values(): client.send_queue.append(data) poll.register(client.sock, select.POLLOUT)
def broadcast_msg(msg): """ Add message to all connected clients' queues """ data = tincanchat.prep_msg(msg) for client in clients.values(): client.send_queue.append(data) poll.register(client.sock, select.POLLOUT)
def broadcast_msg(msg): data = tincanchat.prep_msg(msg) for client in clients.values(): client.send_queue.append(data) poll.register(client.sock, select.POLLOUT)