def run(self): if not self.__socket: raise('socket is None') while True: buffers_tmp = self.__socket.recv(self.__buffers_tmp_len) self.__buffers += buffers_tmp self.__buffers_len += len(buffers_tmp) while True: if self.__buffers_len > self.__head_len: head_buff = self.__buffers[:2] package_len = packet_util.read_u16(head_buff) if self.__buffers_len >= self.__head_len + package_len: packet_id_buff = self.__buffers[2:4] packet_buff = self.__buffers[4:package_len + self.__head_len + 2] packet_id = packet_util.read_u16(packet_id_buff) body_len = self.__head_len + package_len self.__buffers = self.__buffers[body_len:] self.__buffers_len -= body_len packet = Packet(packet_buff) self.dispath(packet_id, packet) else: break else: break
def run(self): if not self.__socket: raise ('socket is None') while True: buffers_tmp = self.__socket.recv(self.__buffers_tmp_len) self.__buffers += buffers_tmp self.__buffers_len += len(buffers_tmp) while True: if self.__buffers_len > self.__head_len: head_buff = self.__buffers[:2] package_len = packet_util.read_u16(head_buff) if self.__buffers_len >= self.__head_len + package_len: packet_id_buff = self.__buffers[2:4] packet_buff = self.__buffers[4:package_len + self.__head_len + 2] packet_id = packet_util.read_u16(packet_id_buff) body_len = self.__head_len + package_len self.__buffers = self.__buffers[body_len:] self.__buffers_len -= body_len packet = Packet(packet_buff) self.dispath(packet_id, packet) else: break else: break
def run(self): if not self.__socket: raise ('socket is None') reqTestXX = pb.ReqTestXX() reqTestXX.id_u8 = 255 reqTestXX.id_u16 = 65535 reqTestXX.id_u32 = 65535666 reqTestXX.repeat_id_u8 = [254, 255] reqTestXX.optional_id_u8 = 255 self.send(reqTestXX.encode()) while True: buffers_tmp = self.__socket.recv(self.__buffers_tmp_len) self.__buffers += buffers_tmp self.__buffers_len += len(buffers_tmp) while True: if self.__buffers_len > self.__head_len: head_buff = self.__buffers[:2] package_len = packet_util.read_u16(head_buff) if self.__buffers_len >= self.__head_len + package_len: packet_id_buff = self.__buffers[2:4] packet_buff = self.__buffers[4:package_len + self.__head_len + 2] packet_id = packet_util.read_u16(packet_id_buff) body_len = self.__head_len + package_len self.__buffers = self.__buffers[body_len:] self.__buffers_len -= body_len packet = Packet(packet_buff) self.dispath(packet_id, packet) else: break else: break
def run(self): if not self.__socket: raise('socket is None') reqTestXX = pb.ReqTestXX() reqTestXX.id_u8 = 255 reqTestXX.id_u16 = 65535 reqTestXX.id_u32 = 65535666 reqTestXX.repeat_id_u8 = [254,255] reqTestXX.optional_id_u8 = 255 self.send(reqTestXX.encode()) while True: buffers_tmp = self.__socket.recv(self.__buffers_tmp_len) self.__buffers += buffers_tmp self.__buffers_len += len(buffers_tmp) while True: if self.__buffers_len > self.__head_len: head_buff = self.__buffers[:2] package_len = packet_util.read_u16(head_buff) if self.__buffers_len >= self.__head_len + package_len: packet_id_buff = self.__buffers[2:4] packet_buff = self.__buffers[4:package_len + self.__head_len + 2] packet_id = packet_util.read_u16(packet_id_buff) body_len = self.__head_len + package_len self.__buffers = self.__buffers[body_len:] self.__buffers_len -= body_len packet = Packet(packet_buff) self.dispath(packet_id, packet) else: break else: break