(Classic) PDS
This Service is an example PDS Service. It currently stores things within entity variables.
This service's functions can be used by importing the service as a module. This can be done like so:
use module a169x676 alias pds
The PDS service provides 3 functions and responds to 5 events. The functions are as follows:
Functions
get_item
The get_item function takes two arguments. Both are required.
- namespace
- A string identifying the namespace of the stored data
- keyvalue
- The name of the key you wish to retrieve
get_me
The get_me function takes one required argument.
- keyvalue
- A string identifying the item from the entity's profile you wish to retrieve
get_all_me
The get_all_me function accepts no arguments. It returns all items from the entity's profile.
myProfile = pds:get_all_me(); returns at least ... { "myProfileName" : "John Smith", "myProfilePhoto" : "data: image/png;base64, ...", "myProfileNotes" : "Nothing to see here, move along", "myProfileDescription" : "Be all you can bee" }
Events
The PDS Service responds to 5 events. The events are as follows:
pds new_data_available
This event should be raised whenever you wish to add an item to the PDS. You should include three attributes to your event when raising it:
- namespace
- A string containing the namespace to store the data
- keyvalue
- A string containing the key to store the data under
- value
- This attribute can be a string, number, boolean, hash, or array
- This data gets stored in the PDS under the namespace and key
pds new_map_available
This event should be raised when you wish to update all items under a namespace. The items should be in a hash with the key being the value to update and the values being the values to be set as.
Example hash:
{ "test": "data", "foo": "bar }
This hash should be supplied as an attribute named mapvalues
. The attributes in general are:
- mapvalues
- A hash containing the name-value pairs to store
- namespace
- A string containing the namespace to store the data
// These two new_data_available events are equivilent to the new_map_available event raise pds event new_data_available with namespace = "test" and keyvalue = "foo" and value = "bar"; raise pds event new_data_available with namespace = "test" and keyvalue = "bar" and value = "cheese"; raise pds event new_map_available with namespace = "test" and mapvalues = { "foo" : "bar", "bar" : "cheese" };
pds new_profile_item_available
This event should be raised whenever you wish to change the entity's profile within the PDS. Since the data is going into the profile, namespace is not used on this event. All of the attributes supplied with this event are stored into the PDS.
pds new_doorbell_available
This event updates the doorbell ECI stored in the entity's profile within the PDS. The event attributes used are as follows:
- doorbell
- The ECI of the entity's new doorbell
web sessionReady
This event gets raised within the CloudOS when the user logs in. There are two things that happen when the session is ready:
- If no profile is set, set a default profile
- Once logged in, change the CloudOS avartar with the user's avatar
Copyright Picolabs | Licensed under Creative Commons.