Пример #1
0
 def handle_control_message(self, message):
     msg = Message.parse(message)
     if msg.msgClass == MessageClass.SERVICE_REGISTRATION:
         self._store_manifest(msg.payload)
     elif msg.msgClass == MessageClass.DIRECTORY_LISTING:
         for manifest in msg.payload:
             self._store_manifest(manifest)
 def onControlMessage(self, message, details=None):
     msg = Message.parse(message)
     self.log.debug("Received message {msg}", msg=msg)
     if (msg.msgClass == MessageClass.SERVICE_REGISTRATION):
         self._add_manifest_entry(
             msg.payload.copy(),
             details
         )
Пример #3
0
    def handle_service_message(self, message, details=None):
        if details and details.topic:
            msg = Message.parse(message)
            service_uuid = details.topic.split('.')[-1]

            if msg.msgClass == MessageClass.SERVICE_DATA:
                self._store_data_frame(service_uuid, msg.payload)
            elif msg.msgClass == MessageClass.SERVICE_DATA_COMPRESSED:
                state = simplejson.loads(LZString().decompressFromUTF16(
                    msg.payload))
                self._store_data_frame(service_uuid, state, msg.date)
    def onJoin(self, details):
        self.log.info("Session ready")

        yield self.register(self.getServicesList, RPC.GET_DIRECTORY_LISTING)
        yield self.subscribe(self.onControlMessage, Channel.CONTROL, CONTROL_SUBSCRIPTION_OPTIONS)
        self.log.debug("Subscribed to control channel")
        yield self.publish(Channel.CONTROL, Message(MessageClass.INITIALISE_DIRECTORY).serialise())
        self.log.debug("Published init message")
        self.broadcastServicesList()

        liveness = task.LoopingCall(self.checkLiveness)
        liveness.start(10)

        broadcast = task.LoopingCall(self.broadcastServicesList)
        broadcast.start(60)
Пример #5
0
    def handle_analysis_message(self, message, details=None):
        if details and details.topic:
            msg = Message.parse(message)
            if msg.msgClass == MessageClass.ANALYSIS_DATA:
                topic_parts = details.topic.split('/')

                if len(topic_parts) >= 3:
                    service_uuid = topic_parts[1]
                    analysis_module = topic_parts[2]

                    self.log.debug("Received analysis {module} for {uuid}",
                                   module=analysis_module,
                                   uuid=service_uuid)
                    self._in_progress_analyses[service_uuid].setdefault(
                        analysis_module, {}).update(msg.payload)
                else:
                    self.log.warn(
                        "Received analysis packet with malformed topic {topic}",
                        topic=details.topic)
Пример #6
0
 def publish_schedule(self):
     self.publish(Channel.SCHEDULER,
                  Message(MessageClass.SCHEDULE_LISTING,
                          self.listSchedule(),
                          retain=True).serialise(),
                  options=self.publish_options)
 def broadcastServicesList(self):
     self.publish(
         Channel.DIRECTORY,
         Message(MessageClass.DIRECTORY_LISTING, list(self.services.values()), retain=True).serialise(),
         options=self.publish_options
     )