private static class WebHubXmlRpcHandler.WebHubActorImpl extends java.lang.Object implements WebHubActor
Modifier and Type | Field and Description |
---|---|
private ClientAuthorizer |
auth_ |
private java.net.URL |
baseUrl_ |
private KeyGenerator |
keyGen_ |
private ClientProfile |
profile_ |
private java.util.Map |
regMap_ |
private UrlTracker |
urlTracker_ |
private WebHubXmlRpcHandler.URLTranslationHandler |
urlTranslator_ |
Constructor and Description |
---|
WebHubActorImpl(ClientProfile profile,
ClientAuthorizer auth,
KeyGenerator keyGen,
java.net.URL baseUrl,
UrlTracker urlTracker)
Constructor.
|
Modifier and Type | Method and 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.
|
private final ClientProfile profile_
private final ClientAuthorizer auth_
private final KeyGenerator keyGen_
private final java.util.Map regMap_
private final WebHubXmlRpcHandler.URLTranslationHandler urlTranslator_
private final java.net.URL baseUrl_
private final UrlTracker urlTracker_
public WebHubActorImpl(ClientProfile profile, ClientAuthorizer auth, KeyGenerator keyGen, java.net.URL baseUrl, UrlTracker urlTracker)
profile
- hub connection factoryauth
- client authorizerkeyGen
- key generator for private keysbaseUrl
- HTTP server base URLurlTracker
- controls access to translated URLs,
may be null for no controlpublic HttpServer.Handler getUrlTranslationHandler()
public RegInfo register(HttpServer.Request request, java.util.Map securityMap) throws SampException
request
- HTTP request from applicantsecurityMap
- map of required security information
supplied by applicantSampException
public void unregister(java.lang.String clientKey) throws SampException
WebHubActor
unregister
in interface WebHubActor
clientKey
- calling client private keySampException
public void allowReverseCallbacks(java.lang.String clientKey, java.lang.String allow) throws SampException
WebHubActor
WebHubActor.pullCallbacks(java.lang.String, java.lang.String)
to receive callable client-type
callbacks until further notice.allowReverseCallbacks
in interface WebHubActor
clientKey
- calling client private keyallow
- flag indicating that the client will/will not
be pulling callbacks, encoded as a SAMP boolean ("1"/"0")SampException
public java.util.List pullCallbacks(java.lang.String clientKey, java.lang.String timeout) throws SampException
WebHubActor
pullCallbacks
in interface WebHubActor
clientKey
- calling client private keytimeout
- timeout in seconds encoded as a SAMP intCallback
-like maps ready for
processing by the client; may be empty if none are readySampException
public void declareMetadata(java.lang.String clientKey, java.util.Map meta) throws SampException
WebHubActor
declareMetadata
in interface WebHubActor
clientKey
- calling client private keymeta
- Metadata
-like mapSampException
public java.util.Map getMetadata(java.lang.String clientKey, java.lang.String clientId) throws SampException
WebHubActor
getMetadata
in interface WebHubActor
clientKey
- calling client private keyclientId
- public ID for client whose metadata is requiredMetadata
-like mapSampException
public void declareSubscriptions(java.lang.String clientKey, java.util.Map subs) throws SampException
WebHubActor
declareSubscriptions
in interface WebHubActor
clientKey
- calling client private keysubs
- Subscriptions
-like mapSampException
public java.util.Map getSubscriptions(java.lang.String clientKey, java.lang.String clientId) throws SampException
WebHubActor
getSubscriptions
in interface WebHubActor
clientKey
- calling client private keySubscriptions
-like mapSampException
public java.util.List getRegisteredClients(java.lang.String clientKey) throws SampException
WebHubActor
getRegisteredClients
in interface WebHubActor
clientKey
- calling client private keySampException
public java.util.Map getSubscribedClients(java.lang.String clientKey, java.lang.String mtype) throws SampException
WebHubActor
getSubscribedClients
in interface WebHubActor
clientKey
- calling client private keymtype
- MType of interestmtype
SampException
public void notify(java.lang.String clientKey, java.lang.String recipientId, java.util.Map msg) throws SampException
WebHubActor
notify
in interface WebHubActor
clientKey
- calling client private keyrecipientId
- public-id of client to receive messagemsg
- Message
-like mapSampException
public java.util.List notifyAll(java.lang.String clientKey, java.util.Map msg) throws SampException
WebHubActor
notifyAll
in interface WebHubActor
clientKey
- calling client private keymsg
- Message
-like mapSampException
public java.lang.String call(java.lang.String clientKey, java.lang.String recipientId, java.lang.String msgTag, java.util.Map msg) throws SampException
WebHubActor
call
in interface WebHubActor
clientKey
- calling client private keyrecipientId
- public-id of client to receive messagemsgTag
- arbitrary string tagging this message for caller's
benefitmsg
- Message
-like mapSampException
public java.util.Map callAll(java.lang.String clientKey, java.lang.String msgTag, java.util.Map msg) throws SampException
WebHubActor
callAll
in interface WebHubActor
clientKey
- calling client private keymsgTag
- arbitrary string tagging this message for caller's
benefitmsg
- Message
-like mapSampException
public java.util.Map callAndWait(java.lang.String clientKey, java.lang.String recipientId, java.util.Map msg, java.lang.String timeout) throws SampException
WebHubActor
callAndWait
in interface WebHubActor
clientKey
- calling client private keyrecipientId
- public-id of client to receive messagemsg
- Message
-like maptimeout
- timeout in seconds encoded as a SAMP intResponse
-like mapSampException
public void reply(java.lang.String clientKey, java.lang.String msgId, java.util.Map response) throws SampException
WebHubActor
reply
in interface WebHubActor
clientKey
- calling client private keymsgId
- ID associated with earlier sendresponse
- Response
-like mapSampException
public void ping()
WebHubActor
ping
in interface WebHubActor
public void ping(java.lang.String clientKey)
WebHubActor
ping
in interface WebHubActor
clientKey
- ignoredprivate WebHubXmlRpcHandler.Registration getRegistration(java.lang.String privateKey) throws SampException
privateKey
- private key string known by client and hub
to identify the connectionprivateKey
SampException
- if no client is known with that private keyprivate HubConnection getConnection(java.lang.String privateKey) throws SampException
privateKey
- private key string known by client and hub
to identify the connectionprivateKey
SampException
- if no client is known with that private key