Beispiel #1
0
 def start_session(self):
     sid = uuid1()
     self.sample_head = 0
     command = network_message()
     command.storage_command.start_session = True
     command.storage_command.session_id = sid.bytes
     self.protocol.sendMessage(command)
Beispiel #2
0
 def messageReceived(self, message):
     command = message.storage_command
     if command.start_session:
         sid = UUID(bytes=command.session_id)
         self.store.start_session(sid)
         print("Session Started: %s" % sid)
     elif command.stop_session:
         self.store.stop_session()
         print("Session Stopped")
     elif command.show_data:
         if command.start_sample:
             start = command.start_sample
         else:
             start = 0
         
         (timestamp, samples) = self.store.session.query(start)
         message = network_pb2.network_message()
         message.sample_stream.timestamp = timestamp
         message.sample_stream.samples.extend(samples)
         self.sendMessage(message)
     elif command.stream_to:
         if not command.stream_to in self.store.live_stream.hosts:
             self.store.live_stream.hosts.append(command.stream_to)
Beispiel #3
0
 def sendSample(self, timestamp, value):      
     m = network_pb2.network_message()
     m.sample.timestamp = timestamp
     m.sample.value = value
     self.sendMessage(m)
Beispiel #4
0
 def stringReceived(self, data):
     #print("ProtobufProtocol: Received")
     message = network_pb2.network_message()
     message.ParseFromString(data)
     self.messageReceived(message)
Beispiel #5
0
 def stop_session(self):
     self.sample_head = 0
     command = network_message()
     command.storage_command.stop_session = True
     self.protocol.sendMessage(command)
Beispiel #6
0
 def connectionMade(self):
     command = network_message()
     command.storage_command.stream_to = self.transport.getHost().host
     self.sendMessage(command)