public interface RemoteAPI
Modifier and Type | Field and Description |
---|---|
static String |
FLAG_TURTLE
Delimiter in a HTTP response to indicate the serialized ontological
result in turtle starts in the next line
|
static String |
KEY_AUTH
Parameter in the HTTP request for the authorization identification
|
static String |
KEY_CALL
Parameter in a HTTP response for a ServiceCall URI
|
static String |
KEY_METHOD
Parameter in the HTTP request for the method identification
|
static String |
KEY_PARAM
Parameter in the HTTP request for the main parameter of the method
|
static String |
KEY_STATUS
Parameter in a HTTP response for a ServiceCall status
|
static String |
KEY_TO
Parameter in the HTTP request for the identification of the addressee
|
static String |
KEY_VERSION
Parameter in the HTTP request (optional) for the version of the client
|
static String |
METHOD_CALLS
Value for CALLS method parameter in the HTTP request
|
static String |
METHOD_PROVIDES
Value for PROVIDES method parameter in the HTTP request
|
static String |
METHOD_REGISTER
Value for REGISTER method parameter in the HTTP request
|
static String |
METHOD_RESPONSES
Value for RESPONSE method parameter in the HTTP request
|
static String |
METHOD_SENDC
Value for SENDC method parameter in the HTTP request
|
static String |
METHOD_SUBSCRIBEC
Value for SUBSCRIBEC method parameter in the HTTP request
|
static String |
METHOD_UNREGISTER
Value for UNREGISTER method parameter in the HTTP request
|
static int |
REMOTE_GCM
Identifier for remote endpoints using Google Cloud Messaging
|
static int |
REMOTE_POST
Identifier for remote endpoints using HTTP POST
|
static int |
REMOTE_UNKNOWN
Identifier for remote endpoints using unknown protocols
|
Modifier and Type | Method and Description |
---|---|
String |
callS(String id,
String srequest)
Calls a Service with a Service Request.
|
String |
getCryptKey(String id)
Get the encryption key to use to encrypt messages via GCM if proceeds.
|
void |
provideS(String id,
String sprofile)
Registers a Service Profile.
|
String |
register(String id,
String remote)
Register a client remote node in the server.
|
void |
sendC(String id,
String cevent)
Sends a Context Event.
|
void |
subscribeC(String id,
String cpattern)
Subscribes for Context Events.
|
void |
unregister(String id)
Unregister a client remote node in the server.
|
void |
unregisterAll()
Unregister all the client remote node in the server.
|
static final String METHOD_REGISTER
static final String METHOD_SENDC
static final String METHOD_SUBSCRIBEC
static final String METHOD_CALLS
static final String METHOD_PROVIDES
static final String METHOD_UNREGISTER
static final String METHOD_RESPONSES
static final String KEY_AUTH
static final String KEY_METHOD
static final String KEY_PARAM
static final String KEY_VERSION
static final String KEY_TO
static final String KEY_STATUS
static final String KEY_CALL
static final String FLAG_TURTLE
static final int REMOTE_POST
static final int REMOTE_GCM
static final int REMOTE_UNKNOWN
String register(String id, String remote) throws Exception
This method must be called once before any other method. Subsequent calls will only update the remote endpoint reference, not restart the registration.
id
- The token that uniquely identifies the client remote noderemote
- Identifies the client endpoint where the push responses and
callbacks will be sent by the serverException
- If any problem arose during the registration and it was not
successfulvoid sendC(String id, String cevent) throws Exception
The server will automatically create a Context Publisher if this is the first time the method is called. If the passed event contains ContextProvider information, it is used to instantiate the Publisher. Otherwise the missing information is automatically generated: The Publisher is described as either a Gauge or a Controller depending on if you are providing Services (you called method PROVIDES before). The URI of the Provider is then set to http://ontology.universAAL.org/SimpleUAAL .owl#ContextEventsProvider and it cannot be changed. The pattern that describes the provided events of this provider is empty, which means it can publish any type of event. Notice this Provider info is set ONLY THE FIRST TIME and cannot be changed by later calls.
id
- The token that uniquely identifies the client remote nodecevent
- The serialized ContextEventException
- If it was not possible to send the eventvoid subscribeC(String id, String cpattern) throws Exception
The server will automatically create a new Context Subscriber each time this method is called. All Context Events that match the pattern will be sent back to the client endpoint. Since every call to this method creates a new subscriber, you should be careful with how many times you call this method. Usually, a limited number of subscriptions is needed. Remember that you can combine different patterns to be handled by a single subscriber.
id
- The token that uniquely identifies the client remote nodecpattern
- The serialized ContextEventPatternException
- If it was not possible to subscribe to the eventsString callS(String id, String srequest) throws Exception
The server will automatically create an internal Default Service Caller if this is the first time the method is called. The call to the service is synchronous: this method returns the response of the call straight from Service Bus.
id
- The token that uniquely identifies the client remote nodesrequest
- The serialized ServiceRequestException
- If it was not possible to issue the requestvoid provideS(String id, String sprofile) throws Exception
The server will automatically create a new Service Callee each time this method is called. All ServiceCalls addressed to this profile will be sent back to the client endpoint. Since every call to this method creates a new callee, you should be careful with how many times you call this method. Usually, a limited number of callees is needed.
id
- The token that uniquely identifies the client remote nodesprofile
- The serialized ServiceProfileException
- If it was not possible to register the profilevoid unregister(String id) throws Exception
It frees all associated resources allocated to the client by previous calls. No callbacks will be sent to the client endpoint after this, and no further method calls will be allowed.
id
- The token that uniquely identifies the client remote nodeException
- If it was not possible to unregister the clientvoid unregisterAll()
This is only for use when the Remote API module is shutting down. It frees all associated resources allocated to the all client by previous calls. No callbacks will be sent to the client endpoint after this, and no further method calls will be allowed. This avoids universAAL wrappers being kept running in the MW when there is no one to answer to them. Unlike unregister(), it does not throw Exception: if a node fails to be unregistered, an error is logged and it continues with the rest.
Copyright © 2018 universAAL Consortium. All rights reserved.