예제 #1
0
    def create_client_configuration(self, uuid):
        '''
        Return information to pass to the client so it can configure its expectations accordingly.
        This is built from the input of various components in the thywill system, and the provided
        additional_parameters.
        
        :Parameters:
            - uuid: a string ID for this client
            
        :Return:
            ClientConfiguration object
        '''

        # create a client configuration object. The additional parameters
        # dictionary is used to add in the uuid for a specific client.
        config = DjangoClientConfiguration(uuid)

        # add data from this component
        self._bootstrap_client(uuid, config)

        # add data from the other components; ordering should be such that
        # the application interface component is last, as that gives it a chance
        # to see what else is set.
        LogComponent.factory()._bootstrap_client(uuid, config)
        PushComponent.factory()._bootstrap_client(uuid, config)
        DatabaseComponent.factory()._bootstrap_client(uuid, config)
        ApplicationInterfaceComponent.factory()._bootstrap_client(uuid, config)

        return config
예제 #2
0
    def create_client_configuration(self, uuid):
        """
        Return information to pass to the client so it can configure its expectations accordingly.
        This is built from the input of various components in the thywill system, and the provided
        additional_parameters.
        
        :Parameters:
            - uuid: a string ID for this client
            
        :Return:
            ClientConfiguration object
        """

        # create a client configuration object. The additional parameters
        # dictionary is used to add in the uuid for a specific client.
        config = DjangoClientConfiguration(uuid)

        # add data from this component
        self._bootstrap_client(uuid, config)

        # add data from the other components; ordering should be such that
        # the application interface component is last, as that gives it a chance
        # to see what else is set.
        LogComponent.factory()._bootstrap_client(uuid, config)
        PushComponent.factory()._bootstrap_client(uuid, config)
        DatabaseComponent.factory()._bootstrap_client(uuid, config)
        ApplicationInterfaceComponent.factory()._bootstrap_client(uuid, config)

        return config
예제 #3
0
def send_message_to_client(uuid, raw_message):
    '''
    Send a message on to the client via the Application Interface.
    
    :Parameters:
        - uuid: a string ID for this client
        - raw_message: the message to be sent
    '''
    ApplicationInterfaceComponent.factory().send_message_to_client(uuid, raw_message);
예제 #4
0
def send(request):
    '''
    AJAX response: Send a client-originated message into the currently active application.
    
    :Parameters:
        - request: HttpRequest
            
    :Return:
        HttpResponse
    '''
    uuid = __ensure_uuid(request)
    if 'message' in request.POST:
        message = request.POST['message']
        LogComponent.debug(['django.requests.send', 'AJAX message from client', uuid, message])
        ApplicationInterfaceComponent.factory().client_message_received(uuid, message)
    else:
        LogComponent.debug(['django.requests.send', 'Invalid POST request', uuid, request.POST])
    
    # TODO return confirmation of some sort?
    
    
    return HttpResponse()