Class WebHubXmlRpcHandler.WebHubActorImpl

  • All Implemented Interfaces:
    WebHubActor
    Enclosing class:
    WebHubXmlRpcHandler

    private static class WebHubXmlRpcHandler.WebHubActorImpl
    extends java.lang.Object
    implements WebHubActor
    WebHubActor implementation.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void allowReverseCallbacks​(java.lang.String clientKey, java.lang.String allow)
      Indicates that the client will or will not be calling WebHubActor.pullCallbacks(java.lang.String, java.lang.String) to receive callable client-type callbacks until further notice.
      java.lang.String call​(java.lang.String clientKey, java.lang.String recipientId, java.lang.String msgTag, java.util.Map msg)
      Sends a message to a given client expecting a response.
      java.util.Map callAll​(java.lang.String clientKey, java.lang.String msgTag, java.util.Map msg)
      Sends a message to all subscribed clients expecting responses.
      java.util.Map callAndWait​(java.lang.String clientKey, java.lang.String recipientId, java.util.Map msg, java.lang.String timeout)
      Sends a message synchronously to a client.
      void declareMetadata​(java.lang.String clientKey, java.util.Map meta)
      Declares metadata for the calling client.
      void declareSubscriptions​(java.lang.String clientKey, java.util.Map subs)
      Declares subscription information for the calling client.
      private HubConnection getConnection​(java.lang.String privateKey)
      Returns the connection object associated with a given private key.
      java.util.Map getMetadata​(java.lang.String clientKey, java.lang.String clientId)
      Returns metadata for a given client.
      java.util.List getRegisteredClients​(java.lang.String clientKey)
      Returns a list of the public-ids of all currently registered clients.
      private WebHubXmlRpcHandler.Registration getRegistration​(java.lang.String privateKey)
      Returns the registration object associated with a given private key.
      java.util.Map getSubscribedClients​(java.lang.String clientKey, java.lang.String mtype)
      Returns a map of the clients subscribed to a given MType.
      java.util.Map getSubscriptions​(java.lang.String clientKey, java.lang.String clientId)
      Returns subscriptions for a given client.
      HttpServer.Handler getUrlTranslationHandler()
      Returns a handler suitable for performing URL translations on behalf of sandboxed clients as required by the Web Profile.
      void notify​(java.lang.String clientKey, java.lang.String recipientId, java.util.Map msg)
      Sends a message to a given client without wanting a response.
      java.util.List notifyAll​(java.lang.String clientKey, java.util.Map msg)
      Sends a message to all subscribed clients without wanting a response.
      void ping()
      Throws an exception if service is not operating.
      void ping​(java.lang.String clientKey)
      Throws an exception if service is not operating.
      java.util.List pullCallbacks​(java.lang.String clientKey, java.lang.String timeout)
      Waits for up to a certain length of time for any callbacks to be delivered.
      RegInfo register​(HttpServer.Request request, java.util.Map securityMap)
      Attempt client registration.
      void reply​(java.lang.String clientKey, java.lang.String msgId, java.util.Map response)
      Responds to a previously sent message.
      void unregister​(java.lang.String clientKey)
      Unregisters a registered client.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • WebHubActorImpl

        public WebHubActorImpl​(ClientProfile profile,
                               ClientAuthorizer auth,
                               KeyGenerator keyGen,
                               java.net.URL baseUrl,
                               UrlTracker urlTracker)
        Constructor.
        Parameters:
        profile - hub connection factory
        auth - client authorizer
        keyGen - key generator for private keys
        baseUrl - HTTP server base URL
        urlTracker - controls access to translated URLs, may be null for no control
    • Method Detail

      • getUrlTranslationHandler

        public HttpServer.Handler getUrlTranslationHandler()
        Returns a handler suitable for performing URL translations on behalf of sandboxed clients as required by the Web Profile.
        Returns:
        url translation handler
      • register

        public RegInfo register​(HttpServer.Request request,
                                java.util.Map securityMap)
                         throws SampException
        Attempt client registration. An exception is thrown if registration fails for any reason.
        Parameters:
        request - HTTP request from applicant
        securityMap - map of required security information supplied by applicant
        Returns:
        registration information if registration is successful
        Throws:
        SampException
      • unregister

        public void unregister​(java.lang.String clientKey)
                        throws SampException
        Description copied from interface: WebHubActor
        Unregisters a registered client.
        Specified by:
        unregister in interface WebHubActor
        Parameters:
        clientKey - calling client private key
        Throws:
        SampException
      • pullCallbacks

        public java.util.List pullCallbacks​(java.lang.String clientKey,
                                            java.lang.String timeout)
                                     throws SampException
        Description copied from interface: WebHubActor
        Waits for up to a certain length of time for any callbacks to be delivered.
        Specified by:
        pullCallbacks in interface WebHubActor
        Parameters:
        clientKey - calling client private key
        timeout - timeout in seconds encoded as a SAMP int
        Returns:
        list of Callback-like maps ready for processing by the client; may be empty if none are ready
        Throws:
        SampException
      • declareMetadata

        public void declareMetadata​(java.lang.String clientKey,
                                    java.util.Map meta)
                             throws SampException
        Description copied from interface: WebHubActor
        Declares metadata for the calling client.
        Specified by:
        declareMetadata in interface WebHubActor
        Parameters:
        clientKey - calling client private key
        meta - Metadata-like map
        Throws:
        SampException
      • getMetadata

        public java.util.Map getMetadata​(java.lang.String clientKey,
                                         java.lang.String clientId)
                                  throws SampException
        Description copied from interface: WebHubActor
        Returns metadata for a given client.
        Specified by:
        getMetadata in interface WebHubActor
        Parameters:
        clientKey - calling client private key
        clientId - public ID for client whose metadata is required
        Returns:
        Metadata-like map
        Throws:
        SampException
      • getSubscriptions

        public java.util.Map getSubscriptions​(java.lang.String clientKey,
                                              java.lang.String clientId)
                                       throws SampException
        Description copied from interface: WebHubActor
        Returns subscriptions for a given client.
        Specified by:
        getSubscriptions in interface WebHubActor
        Parameters:
        clientKey - calling client private key
        Returns:
        Subscriptions-like map
        Throws:
        SampException
      • getRegisteredClients

        public java.util.List getRegisteredClients​(java.lang.String clientKey)
                                            throws SampException
        Description copied from interface: WebHubActor
        Returns a list of the public-ids of all currently registered clients.
        Specified by:
        getRegisteredClients in interface WebHubActor
        Parameters:
        clientKey - calling client private key
        Returns:
        list of Strings
        Throws:
        SampException
      • getSubscribedClients

        public java.util.Map getSubscribedClients​(java.lang.String clientKey,
                                                  java.lang.String mtype)
                                           throws SampException
        Description copied from interface: WebHubActor
        Returns a map of the clients subscribed to a given MType.
        Specified by:
        getSubscribedClients in interface WebHubActor
        Parameters:
        clientKey - calling client private key
        mtype - MType of interest
        Returns:
        map in which the keys are the public-ids of clients subscribed to mtype
        Throws:
        SampException
      • notify

        public void notify​(java.lang.String clientKey,
                           java.lang.String recipientId,
                           java.util.Map msg)
                    throws SampException
        Description copied from interface: WebHubActor
        Sends a message to a given client without wanting a response.
        Specified by:
        notify in interface WebHubActor
        Parameters:
        clientKey - calling client private key
        recipientId - public-id of client to receive message
        msg - Message-like map
        Throws:
        SampException
      • notifyAll

        public java.util.List notifyAll​(java.lang.String clientKey,
                                        java.util.Map msg)
                                 throws SampException
        Description copied from interface: WebHubActor
        Sends a message to all subscribed clients without wanting a response.
        Specified by:
        notifyAll in interface WebHubActor
        Parameters:
        clientKey - calling client private key
        msg - Message-like map
        Returns:
        list of public-ids for clients to which the notify will be sent
        Throws:
        SampException
      • call

        public java.lang.String call​(java.lang.String clientKey,
                                     java.lang.String recipientId,
                                     java.lang.String msgTag,
                                     java.util.Map msg)
                              throws SampException
        Description copied from interface: WebHubActor
        Sends a message to a given client expecting a response.
        Specified by:
        call in interface WebHubActor
        Parameters:
        clientKey - calling client private key
        recipientId - public-id of client to receive message
        msgTag - arbitrary string tagging this message for caller's benefit
        msg - Message-like map
        Returns:
        message ID
        Throws:
        SampException
      • callAll

        public java.util.Map callAll​(java.lang.String clientKey,
                                     java.lang.String msgTag,
                                     java.util.Map msg)
                              throws SampException
        Description copied from interface: WebHubActor
        Sends a message to all subscribed clients expecting responses.
        Specified by:
        callAll in interface WebHubActor
        Parameters:
        clientKey - calling client private key
        msgTag - arbitrary string tagging this message for caller's benefit
        msg - Message-like map
        Returns:
        public-id->msg-id map for clients to which an attempt to send the call will be made
        Throws:
        SampException
      • callAndWait

        public java.util.Map callAndWait​(java.lang.String clientKey,
                                         java.lang.String recipientId,
                                         java.util.Map msg,
                                         java.lang.String timeout)
                                  throws SampException
        Description copied from interface: WebHubActor
        Sends a message synchronously to a client.
        Specified by:
        callAndWait in interface WebHubActor
        Parameters:
        clientKey - calling client private key
        recipientId - public-id of client to receive message
        msg - Message-like map
        timeout - timeout in seconds encoded as a SAMP int
        Returns:
        Response-like map
        Throws:
        SampException
      • reply

        public void reply​(java.lang.String clientKey,
                          java.lang.String msgId,
                          java.util.Map response)
                   throws SampException
        Description copied from interface: WebHubActor
        Responds to a previously sent message.
        Specified by:
        reply in interface WebHubActor
        Parameters:
        clientKey - calling client private key
        msgId - ID associated with earlier send
        response - Response-like map
        Throws:
        SampException
      • ping

        public void ping()
        Description copied from interface: WebHubActor
        Throws an exception if service is not operating.
        Specified by:
        ping in interface WebHubActor
      • ping

        public void ping​(java.lang.String clientKey)
        Description copied from interface: WebHubActor
        Throws an exception if service is not operating.
        Specified by:
        ping in interface WebHubActor
        Parameters:
        clientKey - ignored
      • getRegistration

        private WebHubXmlRpcHandler.Registration getRegistration​(java.lang.String privateKey)
                                                          throws SampException
        Returns the registration object associated with a given private key.
        Parameters:
        privateKey - private key string known by client and hub to identify the connection
        Returns:
        registration object for client with key privateKey
        Throws:
        SampException - if no client is known with that private key
      • getConnection

        private HubConnection getConnection​(java.lang.String privateKey)
                                     throws SampException
        Returns the connection object associated with a given private key.
        Parameters:
        privateKey - private key string known by client and hub to identify the connection
        Returns:
        connection object for client with key privateKey
        Throws:
        SampException - if no client is known with that private key