Class HubCallableClient

  • All Implemented Interfaces:
    CallableClient

    class HubCallableClient
    extends java.lang.Object
    implements CallableClient
    CallableClient implementation used by the hub client. This isn't exactly essential, but it enables the hub client (the client which represents the hub itself) to subscribe to some MTypes. Possibly useful for testing purposes etc.
    Since:
    28 Jan 2011
    Author:
    Mark Taylor
    • Constructor Detail

      • HubCallableClient

        public HubCallableClient​(HubConnection connection,
                                 AbstractMessageHandler[] handlers)
        Constructs a HubCallableClient with a given set of handlers.
        Parameters:
        connection - connection to hub service
        handlers - array of message handlers
    • Method Detail

      • receiveCall

        public void receiveCall​(java.lang.String senderId,
                                java.lang.String msgId,
                                Message msg)
                         throws SampException
        Description copied from interface: CallableClient
        Receives a message for which a response is required. The implementation must take care to call the hub's reply method at some future point.
        Specified by:
        receiveCall in interface CallableClient
        Parameters:
        senderId - public ID of sending client
        msgId - message identifier for later use with reply
        msg - message
        Throws:
        SampException
      • receiveResponse

        public void receiveResponse​(java.lang.String responderId,
                                    java.lang.String msgTag,
                                    Response response)
                             throws SampException
        Description copied from interface: CallableClient
        Receives a response to a message previously sent by this client.
        Specified by:
        receiveResponse in interface CallableClient
        Parameters:
        responderId - public ID of responding client
        msgTag - client-defined tag labelling previously-sent message
        response - returned response object
        Throws:
        SampException
      • getSubscriptions

        public Subscriptions getSubscriptions()
        Returns the subscriptions corresponding to the messages that this receiver can deal with.
        Returns:
        subscriptions list
      • getHandler

        private AbstractMessageHandler getHandler​(java.lang.String mtype)
                                           throws SampException
        Returns a handler owned by this callable client which can handle a given MType. If more than one applies, the first one encountered is returned.
        Parameters:
        mtype - MType to handle
        Returns:
        handler for mtype
        Throws:
        SampException - if no suitable handler exists