def send_data(self, code, msg='', data=None): b_data = tools.encode_dict(data) size = len(b_data) if data else int() protocol = dict(code=code, msg=msg, size=size) self.before_send(protocol) if data: self.base_socket.send_all(b_data) return
def before_send(self, protocol): self.base_socket.send_all(self.padding(tools.encode_dict(protocol)))