def event(self, cuuid, host, euuid, event_data, timestamp, priority):
        """This function will process event packets and send them to legal
        checks.

        Args:
          cuuid (string): The client uuid that the event came from.
          host (tuple): The (address, port) tuple of the client.
          euuid (string): The event uuid of the specific event.
          event_data (any): The event data that we will be sending to the
            middleware to be judged and executed.
          timestamp (string): The client provided timestamp of when the event
            was created.
          priority (string): The priority of the event. This is normally set to
            either "normal" or "high". If an event was sent with a high
            priority, then the client will not wait for a response from the
            server before executing the event locally.

        Returns:
          A LEGAL/ILLEGAL response to be sent to the client.

        """

        # Set the initial response to none
        response = None

        # If the host we're sending to is using encryption, get their key to
        # encrypt.
        if host in self.encrypted_hosts:
            logger.debug("Encrypted!")
            client_key = self.registry[cuuid]["encryption"]
        else:
            logger.debug("Not encrypted :<")
            client_key = None

        # Get the port and host
        port = host[1]
        host = host[0]

        # First, we need to check if the request is coming from a registered
        # client. If it's not coming from a registered client, we tell them to
        # fuck off and register first.
        if not self.is_registered(cuuid, host):
            logger.warning("<%s> Sending BYE EVENT: Client not registered." % cuuid)
            response = serialize_data({"method": "BYE EVENT",
                                       "data": "Not registered"},
                                      self.compression,
                                      self.encryption, client_key)
            return response

        # Check our stored event uuid's to see if we're already processing
        # this event.
        if euuid in self.event_uuids:
            logger.warning("<%s> Event ID is already being processed: %s" % (cuuid,
                                                                             euuid))
            # If we're already working on this event, return none so we do not
            # reply to the client
            return response

        # If we're not already processing this event, store the event uuid
        # until we receive a confirmation from the client that it received our
        # judgement.
        self.event_uuids[euuid] = 0
        logger.debug("<%s> <euuid:%s> Currently processing events: "
                     "%s" % (cuuid, euuid, str(self.event_uuids)))
        logger.debug("<%s> <euuid:%s> New event being processed" % (cuuid, euuid))
        logger.debug("<%s> <euuid:%s> Event Data: %s" % (cuuid,
                                                         euuid,
                                                         pformat(event_data)))

        # Send the event to the game middleware to determine if the event is
        # legal or not and to process the event in the Game Server if it is
        # legal.
        if self.middleware.event_legal(cuuid, euuid, event_data):
            logger.debug("<%s> <euuid:%s> Event LEGAL. Sending judgement "
                         "to client." % (cuuid, euuid))
            response = serialize_data({"method": "LEGAL",
                                       "euuid": euuid,
                                       "priority": priority},
                                      self.compression,
                                      self.encryption, client_key)
            # Execute the event
            thread = threading.Thread(target=self.middleware.event_execute,
                                      args=(cuuid, euuid, event_data)
                                      )
            thread.start()

        else:
            logger.debug("<%s> <euuid:%s> Event ILLEGAL. Sending judgement "
                         "to client." % (cuuid, euuid))
            response = serialize_data({"method": "ILLEGAL",
                                       "euuid": euuid,
                                       "priority": priority},
                                      self.compression,
                                      self.encryption, client_key)

        # Schedule a task to run in x seconds to check to see if we've timed
        # out in receiving a response from the client.
        self.listener.call_later(self.timeout, self.retransmit,
                                 {"euuid": euuid,
                                  "response": response, "cuuid": cuuid})

        return response
def event ( self , cuuid , host , euuid , event_data , timestamp , priority ) : response = None if host in self . encrypted_hosts : logger . debug ( "Encrypted!" ) client_key = self . registry [ cuuid ] [ "encryption" ] else : logger . debug ( "Not encrypted :<" ) client_key = None port = host [ 1 ] host = host [ 0 ] if not self . is_registered ( cuuid , host ) : logger . warning ( "<%s> Sending BYE EVENT: Client not registered." % cuuid ) response = serialize_data ( { "method" : "BYE EVENT" , "data" : "Not registered" } , self . compression , self . encryption , client_key ) return response if euuid in self . event_uuids : logger . warning ( "<%s> Event ID is already being processed: %s" % ( cuuid , euuid ) ) return response self . event_uuids [ euuid ] = 0 logger . debug ( "<%s> <euuid:%s> Currently processing events: " "%s" % ( cuuid , euuid , str ( self . event_uuids ) ) ) logger . debug ( "<%s> <euuid:%s> New event being processed" % ( cuuid , euuid ) ) logger . debug ( "<%s> <euuid:%s> Event Data: %s" % ( cuuid , euuid , pformat ( event_data ) ) ) if self . middleware . event_legal ( cuuid , euuid , event_data ) : logger . debug ( "<%s> <euuid:%s> Event LEGAL. Sending judgement " "to client." % ( cuuid , euuid ) ) response = serialize_data ( { "method" : "LEGAL" , "euuid" : euuid , "priority" : priority } , self . compression , self . encryption , client_key ) thread = threading . Thread ( target = self . middleware . event_execute , args = ( cuuid , euuid , event_data ) ) thread . start ( ) else : logger . debug ( "<%s> <euuid:%s> Event ILLEGAL. Sending judgement " "to client." % ( cuuid , euuid ) ) response = serialize_data ( { "method" : "ILLEGAL" , "euuid" : euuid , "priority" : priority } , self . compression , self . encryption , client_key ) self . listener . call_later ( self . timeout , self . retransmit , { "euuid" : euuid , "response" : response , "cuuid" : cuuid } ) return response
This function will process event packets and send them to legal
        checks.

        Args:
          cuuid (string): The client uuid that the event came from.
          host (tuple): The (address, port) tuple of the client.
          euuid (string): The event uuid of the specific event.
          event_data (any): The event data that we will be sending to the
            middleware to be judged and executed.
          timestamp (string): The client provided timestamp of when the event
            was created.
          priority (string): The priority of the event. This is normally set to
            either "normal" or "high". If an event was sent with a high
            priority, then the client will not wait for a response from the
            server before executing the event locally.

        Returns:
          A LEGAL/ILLEGAL response to be sent to the client.