Exemple #1
0
 def serialize(self):
     session = samples_pb2.session()
     session.session_id = self.sid.bytes
     
     for i in range(0,4):
         channel = session.channels.add()
         channel.channel_number = i
         channel.blocks.extend(map(lambda x: x.bytes, self.blocks[i]))
     
     return session.SerializeToString()
Exemple #2
0
 def deserialise(serialized):
     session_pb = samples_pb2.session()
     session_pb.ParseFromString(serialized)
     # text_format.Merge(serialized, session_pb)
     
     session = Session(UUID(bytes=session_pb.session_id), persistent=True)
     
     for channel in session_pb.channels:
         session.blocks[channel.channel_number] = map(lambda x: UUID(bytes=x), channel.blocks)
     
     return session