This specification is currently a draft under development.

Subscription Event Protocol

The CloudOS Subscription Event Protocol provides an event based model for managing subscriptions between Personal Clouds. The current implementation of the protocol will create a symmetric relationship between both Personal Clouds. In order to use the Subscription Event Protocol the CloudOS ruleset must be installed in the Personal Cloud for both the originator and target.

Subscribe

The system:subscribe event is used to create a channel between two Personal Clouds.

The app wishing to create the subscription signals the CloudOS to do so by raising the system:subscribeevent. This is most often done in a rule postlude as shown in the following example:
fired {
  raise cloudos event subscribe
    with channelName   = "Coworkers Bob+Ted"
    and  namespace     = "MyFriends"
    and  relationship  = "friend-friend"
    and  targetChannel = "3f15b820-af7f-012f-4c6e-00163ebczzzz"
    and  _api = "sky";
}

 

Upon receiving the subscription request, the target cloud raises the following event to the originating cloud:

 

rule receive_subscriptionRequestAdded
  select when cloudos subscriptionRequestAdded
    namespace re/MyFriends/"
    channelName re/Coworkers Bob+Ted/
    relationship re/friend-friend/

 

The Personal Cloud receiving the subscription request will have the following event raised to signal the receipt of a pending subscription request:

 

 

Subscription Approval or Rejection

With the subscription request pending approval, the Personal Cloud which received the request can either approve or reject the request. To approve the subscription request the following event should be raised:

 

fired {
  raise cloudos event subscriptionRequestApproved
    with eventChannel = "3f15b820-af7f-012f-4c6e-00163ebcaaaa"
    and  _api = "sky";
}

 

Once the subscription request is approved both Personal Clouds will receive a callback events raised within each respective Personal Cloud. These events are raised to enable the developer to take additional actions when the Personal Channels are actually created.

 

rule receive_subscriptionRequestAdded
  select when cloudos subscriptionRequestAdded
    namespace re/MyFriends/
    channelName re/Coworkers Bob+Ted/
    relationship re/friend-friend/

 

To reject the subscription request the following event should be raised:
  • domain: cloudos
  • type: subscriptionRequestRejected
  • attributes: eventChannel

 

fired {
  raise cloudos event subscriptionRequestRejected
    with eventChannel = "3f15b820-af7f-012f-4c6e-00163ebcaaaa"
    and  _api = "sky";
}

 

When the subscription request is rejected the following event will be raised with the Personal Cloud:
  • domain: cloudos
  • type: subscriptionRejected
  • attributes: eventChannel, namespace, relationship, channelName

 

rule receive_subscriptionRejected
  select when cloudos subscriptionRejected
    namespace re/MyFriends/
    channelName re/Coworkers Bob+Ted/
    relationship re/friend-friend/

 

And the following event will be raised in the Personal Cloud which made the subscription request:
  • domain: cloudos
  • type: subscriptionRejected
  • attributes: backChannel, namespace, relationship, channelName
rule receive_subscriptionRejected
  select when cloudos subscriptionRejected
    namespace re/MyFriends/
    channelName re/Coworkers Bob+Ted/
    relationship re/friend-friend/

 

Unsubscribe

The system:unsubscribe event is used to remove the Personal Channels between two Personal Clouds.

 

fired {
  raise cloudos event unsubscribe
    with eventChannel = "3f15b820-af7f-012f-4c6e-00163ebcfddfd"
    and  _api = "sky";
}

 

The backChannel attribute uniquely identifies the Personal Channel within the Personal Cloud, and provided to the target Personal Cloud for raising events into the current Personal Cloud. The backChannel is one of the attributes provided by the subscriptionList() function.
During the processing of removing the Personal Channels bewteen the two Personal Clouds callback events are raised within each respective Personal Cloud. These events are raised to enable the developer to take additional actions when the Personal Channels are actually being removed.

 

rule receive_CloudOS_subscriptionRemoved
  select when cloudos CloudOS_subscriptionRemoved
    namespace re/MyFriends/
    channelName re/Coworkers Bob+Ted/
    relationship re/friend-friend/

 

Functions

subscriptionList(namespace, relationship)

The subscriptionList() function will return a map of the subscriptions within the specified namespace and relationship. In order to use the function you must include the CloudOS module as a pragma in the meta section of your ruleset:

use module a169x625 alias CloudOS