The Citizen Hyperty monitors a user’s behavior in a Smart Citizen environment.
This Hyperty observes a standard Context Data Object with:
to be completed
Hyperty Resource Type
ContextUnit
example
{
"scheme": "context",
"id": "1276020076",
"time": 1465070579,
"values": [ {
"type": "availability_context",
"unit": "pres",
"value": 'available' } ]
}
The UserAvailabilityObserver Hyperty provides an API to discover and observe multiple users publishing availability status. The App has to set one listener per observed user to receive events about availability status change.
This function starts user availability status observation and returns one array of UserAvailabilityController instance. For each one, the App has to set a onChange event handler (see below). If no users exist to observe, it returns false
.
<Promise> UserAvailabilityController[] || boolean start()
parameters
No input parameter.
returns
A promise with an array of UserAvailabilityController instances.
This function discovers Hyperties used by users to publish availability status.
<Promise> HypertyInstance[] discoverUsers( string email, string ?domain )
parameters
email the user identifier domain (optional) the domain providing the Hyperty
returns
A promise with an array of discovered HypertyInstance.
This function starts the observation of the availability status managed by a certain Hyperty.
<Promise> UserAvailabilityController observe( HypertyURL hypertyID )
parameters
hyperty the DiscoveredObject of the Hyperty to be observed
returns
A promise with the UserAvailability Data Object Observer for a certain user.
This function stops the observation of the availability status for a certain user.
unobserve( ContextURL availability )
parameters
availability the UserAvailability Data Object Observer URL to be unobserved
Every change of the status triggers a onChange
event of the observed Data:
userAvailability.onChange('*', (event) => {
console.log('New User Availability status :', userAvailability.data.values[0].value);
});
The Hyperty descriptor is:
"UserAvailabilityReporter": {
"sourcePackage": {
"sourceCode": ""
"sourceCodeClassname": "UserAvailabilityObserver",
"encoding": "base64",
"signature": ""
},
"hypertyType": ["availability_context"],
"cguid": 10004,
"version": "0.1",
"description": "Descriptor of UserAvailabilityObserver Hyperty",
"objectName": "UserAvailabilityObserver",
"configuration": {},
"sourcePackageURL": "/sourcePackage",
"language": "javascript",
"signature": "",
"messageSchemas": "",
"dataObjects": [
"https://catalogue.hybroker.rethink.ptinovacao.pt/.well-known/dataschema/Context"
],
"accessControlPolicy": "somePolicy"
}
Since the Hyperty supports the standard context data schema, any Catalog URL for that schema can be used.