def on_bin_message(self, below_nexus, msg_bytes):
        logging.debug("outgoing local nexus got raw msg: %d" % len(msg_bytes))

        msg, err = MessageCodec.wire_decode(msg_bytes,
            shared_seed=self.shared_seed)
        if err:
            logging.error("could not decode msg: %s" % err)
            super().on_bin_message(below_nexus, msg_bytes)
            return
        super().on_message(below_nexus, msg)
Exemple #2
0
    def recv_raw_from_below_cb(self, below_nexus, msg_bytes):
        logging.info("outgoing local nexus got raw msg: %d" % len(msg_bytes))

        msg, err = MessageCodec.wire_decode(msg_bytes,
                                            shared_seed=self.shared_seed)
        if err:
            logging.error("could not decode msg: %s" % err)
            super().recv_raw_from_below_cb(below_nexus, msg_bytes)
            return
        super().recv_from_below_cb(below_nexus, msg)
 def onMessage(self, payload, isBinary):
     logging.info("outgoing message")
     if isBinary:
         logging.info("binary payload: %d bytes" % len(payload))
         shared_seed = self.factory.ms_shared_seed
         msg, err = MessageCodec.wire_decode(payload,
                                             shared_seed=shared_seed)
         if err:
             logging.error("could not decode: %s" % err)
             return
         logging.info("recv msg: %s" % msg)
         self.upward_recv_cb(self, msg)
     else:
         logging.info("text payload: %s" % payload.decode("utf8"))
         logging.error("text payload is unexpected, dropping")
Exemple #4
0
    def onMessage(self, payload, isBinary):
        if isBinary:
            logging.info("binary payload: %d bytes" % len(payload))

            shared_seed = self.factory.ms_shared_seed

            if not shared_seed and MessageCodec.is_cyphertext(payload):
                if self.onbinmessage:
                    self.onbinmessage(self, payload)
                return
            msg, err = MessageCodec.wire_decode(payload,
                                                shared_seed=shared_seed)
            if err:
                logging.error("could not decode: %s" % err)
                return
            logging.info("recv msg: %s" % msg)
            if self.onmessage:
                self.onmessage(self, msg)
        else:
            logging.info("text payload: %s" % payload.decode("utf8"))
            logging.error("text payload is unexpected, dropping")