Processes messages that have been delivered from the transport
        protocol

        Args:
          msg (string): The raw packet data delivered from the transport
            protocol.
          host (tuple): A tuple containing the (address, port) combination of
            the message's origin.

        Returns:
          A formatted response to the client with the results of the processed
          message.

        Examples:
          >>> msg
          {"method": "OHAI Client", "version": "1.0"}
          >>> host
          ('192.168.0.20', 36545)

def handle_message(self, msg, host):
        """Processes messages that have been delivered from the transport
        protocol

        Args:
          msg (string): The raw packet data delivered from the transport
            protocol.
          host (tuple): A tuple containing the (address, port) combination of
            the message's origin.

        Returns:
          A formatted response to the client with the results of the processed
          message.

        Examples:
          >>> msg
          {"method": "OHAI Client", "version": "1.0"}
          >>> host
          ('192.168.0.20', 36545)

        """

        logger.debug("Executing handle_message method.")
        response = None

        # Unserialize the data packet
        # If encryption is enabled, and we've receive the server's public key
        # already, try to decrypt
        if self.encryption and self.server_key:
            msg_data = unserialize_data(msg, self.compression, self.encryption)
        else:
            msg_data = unserialize_data(msg, self.compression)

        # Log the packet
        logger.debug("Packet received: " + pformat(msg_data))

        # If the message data is blank, return none
        if not msg_data:
            return response

        if "method" in msg_data:
            if msg_data["method"] == "OHAI Client":
                logger.debug("<%s> Autodiscover response from server received "
                              "from: %s" % (self.cuuid, host[0]))
                self.discovered_servers[host]= [msg_data["version"], msg_data["server_name"]]
                # Try to register with the discovered server
                if self.autoregistering:
                    self.register(host)
                    self.autoregistering = False

            elif msg_data["method"] == "NOTIFY":
                self.event_notifies[msg_data["euuid"]] = msg_data["event_data"]
                logger.debug("<%s> Notify received" % self.cuuid)
                logger.debug("<%s> Notify event buffer: %s" % (self.cuuid,
                    pformat(self.event_notifies)))

                # Send an OK NOTIFY to the server confirming we got the message
                response = serialize_data(
                    {"cuuid": str(self.cuuid),
                     "method": "OK NOTIFY",
                     "euuid": msg_data["euuid"]},
                    self.compression, self.encryption, self.server_key)

            elif msg_data["method"] == "OK REGISTER":
                logger.debug("<%s> Ok register received" % self.cuuid)
                self.registered = True
                self.server = host

                # If the server sent us their public key, store it
                if "encryption" in msg_data and self.encryption:
                    self.server_key = PublicKey(
                        msg_data["encryption"][0], msg_data["encryption"][1])

            elif (msg_data["method"] == "LEGAL" or
                  msg_data["method"] == "ILLEGAL"):
                logger.debug("<%s> Legality message received" % str(self.cuuid))
                self.legal_check(msg_data)

                # Send an OK EVENT response to the server confirming we
                # received the message
                response = serialize_data(
                    {"cuuid": str(self.cuuid),
                     "method": "OK EVENT",
                     "euuid": msg_data["euuid"]},
                    self.compression, self.encryption, self.server_key)

        logger.debug("Packet processing completed")

        return response