def read_stream(stream): config_message_bytes = Serialization.read_tunnled_message(stream) config_message_protobuf = protocol_proto.ConfigMessage() config_message_protobuf.ParseFromString(config_message_bytes) fields_config = [ f.name for f in config_message_protobuf.fields_config.fields ] config_message = ConfigMessage(fields_config) return config_message
def read_stream(stream): hello_message_bytes = Serialization.read_tunnled_message(stream) hello_message_protobuf = protocol_proto.HelloMessage() hello_message_protobuf.ParseFromString(hello_message_bytes) user_info = \ UserInfo( \ hello_message_protobuf.user_data.user_id, \ hello_message_protobuf.user_data.username, \ hello_message_protobuf.user_data.birthday, \ protocol_proto._USER_GENDER.values_by_number[hello_message_protobuf.user_data.gender].name.lower()[0] \ ) return HelloMessage(user_info)
def read_user_information(self): user_information_bytes = Serialization.read_tunnled_message(self.stream) user_information_protobuf = mind_proto.User() user_information_protobuf.ParseFromString(user_information_bytes) user_information = \ UserInfo( \ user_information_protobuf.user_id, \ user_information_protobuf.username, user_information_protobuf.birthday, mind_proto._USER_GENDER.values_by_number[user_information_protobuf.gender].name.lower()[0]) return user_information
def read_snapshot(self): snapshot_bytes = Serialization.read_tunnled_message(self.stream, expect_eof=True) snapshot_protobuf = mind_proto.Snapshot() snapshot_protobuf.ParseFromString(snapshot_bytes) translation = \ (snapshot_protobuf.pose.translation.x, \ snapshot_protobuf.pose.translation.y, \ snapshot_protobuf.pose.translation.z) rotation = \ (snapshot_protobuf.pose.rotation.x, \ snapshot_protobuf.pose.rotation.y, \ snapshot_protobuf.pose.rotation.z, \ snapshot_protobuf.pose.rotation.w) color_image = \ ColorImage( \ snapshot_protobuf.color_image.width, \ snapshot_protobuf.color_image.height, \ snapshot_protobuf.color_image.data) depth_image = \ DepthImage( \ snapshot_protobuf.depth_image.width, \ snapshot_protobuf.depth_image.height, \ snapshot_protobuf.depth_image.data) depth_image._fix_hardware_size() user_feeling = \ (snapshot_protobuf.feelings.hunger, \ snapshot_protobuf.feelings.thirst, \ snapshot_protobuf.feelings.exhaustion, \ snapshot_protobuf.feelings.happiness) snapshot = \ Snapshot( \ snapshot_protobuf.datetime, \ translation, \ rotation, \ color_image, \ depth_image, \ user_feeling) return snapshot