FLAG_TURTLE, KEY_AUTH, KEY_CALL, KEY_METHOD, KEY_PARAM, KEY_STATUS, KEY_TO, KEY_VERSION, METHOD_CALLS, METHOD_PROVIDES, METHOD_REGISTER, METHOD_RESPONSES, METHOD_SENDC, METHOD_SUBSCRIBEC, METHOD_UNREGISTER, REMOTE_GCM, REMOTE_POST, REMOTE_UNKNOWN
Constructor and Description |
---|
RemoteAPIImpl(ModuleContext ctxt)
Basic constructor.
|
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.
|
boolean |
isPatternAdded(String id,
String cpattern) |
boolean |
isProfileAdded(String id,
String sprofile) |
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.
|
public RemoteAPIImpl(ModuleContext ctxt)
ctxt
- The universAAL contextpublic String register(String id, String remote) throws Exception
RemoteAPI
This method must be called once before any other method. Subsequent calls will only update the remote endpoint reference, not restart the registration.
register
in interface RemoteAPI
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
successfulpublic void sendC(String id, String cevent) throws APIImplException
RemoteAPI
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.
sendC
in interface RemoteAPI
id
- The token that uniquely identifies the client remote nodecevent
- The serialized ContextEventAPIImplException
public void subscribeC(String id, String cpattern) throws APIImplException
RemoteAPI
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.
subscribeC
in interface RemoteAPI
id
- The token that uniquely identifies the client remote nodecpattern
- The serialized ContextEventPatternAPIImplException
public String callS(String id, String srequest) throws APIImplException
RemoteAPI
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.
callS
in interface RemoteAPI
id
- The token that uniquely identifies the client remote nodesrequest
- The serialized ServiceRequestAPIImplException
public void provideS(String id, String sprofile) throws APIImplException
RemoteAPI
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.
provideS
in interface RemoteAPI
id
- The token that uniquely identifies the client remote nodesprofile
- The serialized ServiceProfileAPIImplException
public void unregister(String id) throws APIImplException
RemoteAPI
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.
unregister
in interface RemoteAPI
id
- The token that uniquely identifies the client remote nodeAPIImplException
public void unregisterAll()
RemoteAPI
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.
unregisterAll
in interface RemoteAPI
public String getCryptKey(String id)
RemoteAPI
getCryptKey
in interface RemoteAPI
id
- The token that uniquely identifies the client remote nodeCopyright © 2018 universAAL Consortium. All rights reserved.