Client
Object
VirtualObservatorySAMP.SAMPClientId — TypeSAMPClientIdA simple structure to save the client ID of a SAMP client.
This structure contains a single string field, client_id. It is defined only to avoid type piracy and to resolve some parameter ambiguities in the code.
VirtualObservatorySAMP.SAMPClient — TypeSAMPClient{H <: AbstractSAMPHub}A structure representing a SAMP client.
The same structure is used for clients of a SAMPHub or of SAMPWebHub.
Members
hub: the hub servername: the name of the client (compulsory)key: a string representing the secret key used by the client to contact the serverhub_id: the id the hub has assigned to himself, as aSAMPClientIdclient_id: the id the hud has assigned to the client, as aSAMPClientIdtranslator: the URL translator (only present if the server is aSAMPWebHub)hub_query_by_meta: a string that, if non-void, indicates the mtype accepted by the hub to perform queries by meta (can be "x-samp.query.by-meta" or "samp.query.by-meta")
Constructors
SAMPClient([hub,] name)
register([hub,] name [; metadata])The first form simply create and register the client. The second form, register, also accepts metadata as keywords, which will be sent to the server (see setMetadata).
VirtualObservatorySAMP.register — FunctionSAMPClient{H <: AbstractSAMPHub}A structure representing a SAMP client.
The same structure is used for clients of a SAMPHub or of SAMPWebHub.
Members
hub: the hub servername: the name of the client (compulsory)key: a string representing the secret key used by the client to contact the serverhub_id: the id the hub has assigned to himself, as aSAMPClientIdclient_id: the id the hud has assigned to the client, as aSAMPClientIdtranslator: the URL translator (only present if the server is aSAMPWebHub)hub_query_by_meta: a string that, if non-void, indicates the mtype accepted by the hub to perform queries by meta (can be "x-samp.query.by-meta" or "samp.query.by-meta")
Constructors
SAMPClient([hub,] name)
register([hub,] name [; metadata])The first form simply create and register the client. The second form, register, also accepts metadata as keywords, which will be sent to the server (see setMetadata).
VirtualObservatorySAMP.defaultClient — ConstantdefaultClient::Union{SAMPClient,Nothing}The default client.
Can be obtained (and set, if it is nothing) using getClient.
VirtualObservatorySAMP.getClient — FunctiongetClient()Return the default client.
This function also sets it the first time it is called.
Methods
All methods can use the default client VirtualObservatorySAMP.defaultClient, which is automatically registered using the `VirtualObservatorySAMP.getClient method. This can be handy if one just need to perform queries and not receive messages.
Each registered client (including the default one) should be unregistered by a call to `VirtualObservatorySAMP.unregister when not needed anymore. This is done automatically by the code at the exit of Julia.
VirtualObservatorySAMP.unregister — Functionunregister([client])Unregister client from the associated hub.
VirtualObservatorySAMP.setMetadata — FunctionsetMetadata([client]; metadata)
declareMetadata([client]; metadata)Set the metadata associated with the client.
The metadata are passed as keyword arguments; metadata consisting of non-valid Julia keywords can be passed with the var"long.name" syntax. For example
setMetadata(client; var"samp.description.text"="A fast FITS image displayer")Standard metadata can be entered using a shorter syntax. In particular, the following aliases are recognized
name => samp.name
description => samp.description.text
icon => samp.icon.url
documentation => samp.documentation.urlNote that, by design, if no icon is provided this function uses a standard icon; if no icon is desired, enter icon="" as keyword parameter.
If this function is called multiple times, the latest metadata are kept (all the others are discarded). Both functions are identical: declareMetadata is just an alias for setMetadata, kept to honour the original SAMP command.
VirtualObservatorySAMP.declareMetadata — FunctionsetMetadata([client]; metadata)
declareMetadata([client]; metadata)Set the metadata associated with the client.
The metadata are passed as keyword arguments; metadata consisting of non-valid Julia keywords can be passed with the var"long.name" syntax. For example
setMetadata(client; var"samp.description.text"="A fast FITS image displayer")Standard metadata can be entered using a shorter syntax. In particular, the following aliases are recognized
name => samp.name
description => samp.description.text
icon => samp.icon.url
documentation => samp.documentation.urlNote that, by design, if no icon is provided this function uses a standard icon; if no icon is desired, enter icon="" as keyword parameter.
If this function is called multiple times, the latest metadata are kept (all the others are discarded). Both functions are identical: declareMetadata is just an alias for setMetadata, kept to honour the original SAMP command.
VirtualObservatorySAMP.getMetadata — FunctiongetMetadata([client,] dest=client.client_id)
getMetadata(dest)Return the metadata set for the client dest.
VirtualObservatorySAMP.getSubscriptions — FunctiongetSubscriptions([client,] dest)Return the subscriptions for the client dest.
VirtualObservatorySAMP.getRegisteredClients — FunctiongetRegisteredClients([client])Return a list of all clients registered with the hub of client.
VirtualObservatorySAMP.getSubscribedClients — FunctiongetSubscribedClients([client,] mtype)Return a list of all clients that subscribed to the given mtype.
Base.notify — Methodnotify([client,] dest, mtype [; args...])Notify the message mtype with the optional arguments args to dest.
dest must be the ID of the destination client: this can be obtained from getSubscribedClients or getRegisteredClients.
The optional message arguments can be passed as keywords: as with setMetadata, arguments with non-valid Julia names can be entered as var"long.name"=value.
The alias communicate is used to avoid type piracy.
VirtualObservatorySAMP.notifyAll — FunctionVirtualObservatorySAMP.callAndWait — FunctioncallAndWait([client,] dest, mtype; timeout=0 [, args...])Send the message mtype to dest and wait for the reply.
Arguments to the message can be added as keywords, similarly to notify.
The timeout keyword controls the timeout in seconds: if set to 0 or to a negative number, there is no timeout (this is the default). Note that in this case the client can wait indefinitely.
VirtualObservatorySAMP.findFirstClient — FunctionfindFirstClient([client,] name; key="samp.name")Return the first client with the metadata key = name
Returns nothing if no client is found.
name can be a simple string (and then it must match exactly key), or a regular expression.
Equivalent to first(findFirstClient(client, name)), but with less allocations.
VirtualObservatorySAMP.findAllClients — FunctionfindAllClients([client,] name; key="samp.name")Return all clients with the metadata key = name
name can be a simple string (and then it must match exactly key), or a regular expression.