public abstract class XmlRpcHubConnection extends Object implements HubConnection
HubConnection.setCallable(org.astrogrid.samp.client.CallableClient) method.
This is a useful base class for XML-RPC-based profile implementations,
but it is not perfectly general: some assumptions, compatible
with the Standard Profile, are made about the way that XML-RPC
calls are mapped on to SAMP hub interface calls.| Constructor and Description |
|---|
XmlRpcHubConnection(SampXmlRpcClient xClient,
String prefix,
List registerArgs)
Constructor.
|
| Modifier and Type | Method and Description |
|---|---|
String |
call(String recipientId,
String msgTag,
Map msg)
Sends a message to a given client expecting a response.
|
Map |
callAll(String msgTag,
Map msg)
Sends a message to all subscribed clients expecting responses.
|
Response |
callAndWait(String recipientId,
Map msg,
int timeout)
Sends a message synchronously to a client, waiting for the response.
|
void |
declareMetadata(Map meta)
Declares this registered client's metadata.
|
void |
declareSubscriptions(Map subs)
Declares this registered client's MType subscriptions.
|
Object |
exec(String methodName,
Object[] params)
Makes an XML-RPC call to the SAMP hub represented by this connection.
|
abstract Object |
getClientKey()
Returns an object which is used as the first argument of most
XML-RPC calls to the hub.
|
Metadata |
getMetadata(String clientId)
Returns the metadata for another registered client.
|
RegInfo |
getRegInfo()
Returns the registration information associated with this connection.
|
String[] |
getRegisteredClients()
Returns the list of client public IDs for those clients currently
registered.
|
Map |
getSubscribedClients(String mtype)
Returns a map of subscriptions for a given MType.
|
Subscriptions |
getSubscriptions(String clientId)
Returns the subscriptions for another registered client.
|
void |
notify(String recipientId,
Map msg)
Sends a message to a given client without wanting a response.
|
List |
notifyAll(Map msg)
Sends a message to all subscribed clients without wanting a response.
|
void |
ping()
Tests whether the connection is currently open.
|
Object |
rawExec(String fqName,
List paramList)
Actually makes an XML-RPC call to the SAMP hub represented by this
connection.
|
void |
reply(String msgId,
Map response)
Supplies a response to a previously received message.
|
void |
unregister()
Unregisters the client and terminates this connection.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitsetCallablepublic XmlRpcHubConnection(SampXmlRpcClient xClient, String prefix, List registerArgs) throws SampException
xClient - XML-RPC clientprefix - string prepended to all hub interface method names
to turn them into XML-RPC method namesregisterArgs - arguments to the profile-specific "register"
method to initiate this connectionSampExceptionpublic RegInfo getRegInfo()
HubConnectiongetRegInfo in interface HubConnectionpublic void ping()
throws SampException
HubConnectionping in interface HubConnectionSampException - if the hub has disappeared or communications
are disrupted in some other waypublic void unregister()
throws SampException
HubConnectionunregister in interface HubConnectionSampExceptionpublic void declareMetadata(Map meta) throws SampException
HubConnectiondeclareMetadata in interface HubConnectionmeta - Metadata-like mapSampExceptionpublic Metadata getMetadata(String clientId) throws SampException
HubConnectiongetMetadata in interface HubConnectionclientId - public id for another registered clientSampExceptionpublic void declareSubscriptions(Map subs) throws SampException
HubConnectionOnly permitted if this client is already callable.
declareSubscriptions in interface HubConnectionsubs - Subscriptions-like mapSampExceptionpublic Subscriptions getSubscriptions(String clientId) throws SampException
HubConnectiongetSubscriptions in interface HubConnectionclientId - public id for another registered clientSampExceptionpublic String[] getRegisteredClients() throws SampException
HubConnectiongetRegisteredClients in interface HubConnectionSampExceptionpublic Map getSubscribedClients(String mtype) throws SampException
HubConnectiongetSubscribedClients in interface HubConnectionmtype - MTypemtypeSampExceptionpublic void notify(String recipientId, Map msg) throws SampException
HubConnectionnotify in interface HubConnectionrecipientId - public-id of client to receive messagemsg - Message-like mapSampExceptionpublic List notifyAll(Map msg) throws SampException
HubConnectionnotifyAll in interface HubConnectionmsg - Message-like mapSampExceptionpublic String call(String recipientId, String msgTag, Map msg) throws SampException
HubConnectionreceiveResponse method of this connection's
CallableClient will be called with a
response at some time in the future.
Only permitted if this client is already callable.
call in interface HubConnectionrecipientId - public-id of client to receive messagemsgTag - arbitrary string tagging this message for caller's
benefitmsg - Message-like mapSampExceptionpublic Map callAll(String msgTag, Map msg) throws SampException
HubConnectionreceiveResponse method of this connection's
CallableClient will be called with responses at some
time in the future.
Only permitted if this client is already callable.
callAll in interface HubConnectionmsgTag - arbitrary string tagging this message for caller's
benefitmsg - Message-like mapSampExceptionpublic Response callAndWait(String recipientId, Map msg, int timeout) throws SampException
HubConnectiontimeout
parameter, an exception will result.callAndWait in interface HubConnectionrecipientId - public-id of client to receive messagemsg - Message-like maptimeout - timeout in seconds, or <0 for no timeoutSampExceptionpublic void reply(String msgId, Map response) throws SampException
HubConnectionreply in interface HubConnectionmsgId - ID associated with earlier sendresponse - Response-like mapSampExceptionpublic abstract Object getClientKey()
public Object exec(String methodName, Object[] params) throws SampException
getClientKey() is passed as the first argument
of the XML-RPC call.methodName - unqualified SAMP hub API method nameparams - array of method parametersSampExceptionpublic Object rawExec(String fqName, List paramList) throws SampException
fqName - fully qualified SAMP hub API method nameparamList - list of method parametersSampExceptionCopyright © 2008–2024. All rights reserved.