Options
All
  • Public
  • Public/Protected
  • All
Menu

Interface Coordinator

Coordinator interface that is exposed as an API to be used by third-party developers.

Hierarchy

  • Coordinator

Implemented by

Index

Properties

client

client: Client

The Object representing the client application that is connecting to the Broker.

device

device: Device

The Object representing the Device where this Coordinator is being run. Details will only be populated once a connection is established and the user is authenticated.

instance

instance: Instance

The Object representing the currently running instance of the Coordinator, together with the client application, on the local device. This Object is populated once a connection is established and the user is authenticated. Assuming that Coordinator.subscribeInstances has been called, this Object will be automatically updated every time that the Coordinator has been notified that the currently running local Instance has changed.

proxemics

proxemics: Proxemics

The Object representing the current state of the proxemic relationships between the devices found in the surrounding environment and their capabilities. This Object is populated once a connection is established and the user is authenticated. Assuming that Coordinator.subscribeProxemics has been called, this Object will be automatically updated every time that the Coordinator has been notified that the Proxemics of the currently logged in User have changed.

resource

resource: Resource

The Object representing the default Resource (Resource.default) of the User which is currently connected and logged in through the Coordinator. Assuming that Coordinator.subscribeResources has been called, this Object will be automatically updated every time that the Coordinator has been notified that the default Resource for the User has changed. It will also be opportunistically updated by Coordinator.getResources and {@link Coordinator.updateResource}, i.e., if any of those methods happen to be dealing with the default resource, they will ensure the Coordinator.resource gets updated.

deprecated

This member, or at least its current behavior, should be deprecated/changed in the future so that Coordinator.resource always points to the Resource with the current Coordinator.subscribedResourceId.

Readonly subscribedResourceId

subscribedResourceId: string

A string with the Id of the currently subscribed Resource that the Coordinator is currently subscribed to (e.g., the Resource was selected in the User Interface of a client application) This string is set once a connection is established and the user is authenticated. It will also be updated when a user when Coordinator.subscribeResource is called.

user

user: User

The Object representing the currenrtly logged in User. Details will only be populated once a connection is established and the user is authenticated.

Methods

clearComponentsDistribution

  • clearComponentsDistribution(e: CustomEvent<any>): Promise<Instance>

createResource

  • Creates a new Resource with the given name that belongs to the current User.

    Parameters

    • Optional resourceName: string

      The name of the new resource. If a resource name is not provide an empty string will be used.

    Returns Promise<SharedResource>

    A Promise that once resolved constains the newly created resource in the form an instance of SharedResource class. If an error occurs the Promise will be rejected.

deleteResource

distributeComponents

  • distributeComponents(e: CustomEvent<any>): Promise<Instance[]>

emitEvent

  • emitEvent(value: any, name: string): Promise<any>
  • Emits an event with a given value and a certain name.

    todo

    Add a type definition to encapsulate the sent value.

    todo

    Create an Event class and change Promise to Promise by converting the objects before resolving the Promise.

    Parameters

    • value: any

      A plain object with the information that is associated with the event.

    • name: string

      A string with the name of the event.

    Returns Promise<any>

    A Promise that once resolved contains the created event as it was returned from the broker. If an error occurs the Promise will be rejected.

getActiveInstances

  • getActiveInstances(): Promise<any[]>
  • Gets the active Instances (i.e., Instance.active is true) that the current User has access to (i.e., owned or shared with the user through resource sharing).

    todo

    Change Promise<Array> to Promise<Array> by converting the objects before resolving the Promise.

    Returns Promise<any[]>

    A Promise that once resolved contains the active instances as they were returned from the broker. They should however nearly match the structure of the Instance class. If an error occurs the Promise will be rejected.

getInstances

  • getInstances(extraConditions?: any): Promise<any[]>
  • Gets all the Instances that the current User has access to (i.e., owned or shared with the user through resource sharing).

    todo

    Change Promise<Array> to Promise<Array> by converting the objects before resolving the Promise.

    Parameters

    • Optional extraConditions: any

      Extra conditions that can be added to the query to further filter the returned instances.

    Returns Promise<any[]>

    A Promise that once resolved contains the instances as they were returned from the broker. They should however nearly match the structure of the Instance class. If an error occurs the Promise will be rejected.

getProxemicsState

  • getProxemicsState(): Promise<{}>
  • Gets the Proxemic state (i.e., the Proxemics.state value) for the current User. The state contains the proxemic information and capabilities of a device, i.e., if a device is present in the environment this object should contain a key with its UUID that points to an object that represents the device capabilities.

    Returns Promise<{}>

    A Promise that once resolved constains the Proxemic state (i.e., the Proxemics.state value) for the current User.

getResourceData

  • getResourceData(resourceId?: string): Promise<any>
  • Get the data contents of the Resource with the given Id.

    Parameters

    • Optional resourceId: string

      The Id of the Resource that should have its data content retrieved. If the Id is not provided the Id of the currently selected Resource will be used by default.

    Returns Promise<any>

    A Promise that once resolved contains the data contents of the Resource. If an error occurs the Promise will be rejected.

getResources

  • Gets all the resources that a user has access to (i.e., owned or shared with) in the form of an array instances of the SharedResource class.

    Returns Promise<SharedResource[]>

    A Promise that once resolved constains the array of SharedResources. If an error occurs the Promise will be rejected.

init

  • It initializes the connection to the broker and returns a promise with useful information.

    Returns Promise<[any, Proxemics, string]>

    A Promise that once resolved contains an array with the data of default resource (Coordinator.resource), information about the proxemic state and the Id of the default resource.

isConnected

  • isConnected(): boolean

logout

  • logout(): void

selectResource

  • selectResource(subscriberFunction: (data: any, eventType: string) => void, resourceId: string): Promise<any>
  • It implicitly subscribes to the Resource with the given Id and returns the most up-to-date data stored by the resource.

    Parameters

    • subscriberFunction: (data: any, eventType: string) => void

      The function that gets called when a change to the subscribed Resource is received. The function receives the resource data (Resource.data) and the type of event (created, updated, patched or removed) that generated the change.

        • (data: any, eventType: string): void
        • Parameters

          • data: any
          • eventType: string

          Returns void

    • resourceId: string

      The Id of the Resource that should be subscribed to and have its data content retrieved.

    Returns Promise<any>

setComponentDistribution

  • setComponentDistribution(components: {}, auto?: Boolean, instanceId?: string): Promise<Instance>
  • Sets the distribution of components, and whether it was automatically or manually distributed, for the Instance with the given Id.

    Parameters

    • components: {}

      An object representing the distribution of components where the keys represent the name of the components and the boolean values represent whether the components is shown (true) or not (false).

      • [component: string]: boolean
    • Optional auto: Boolean

      It indicates if the distribution was automatically distributed (true) or manually set by a user (false). The distribution is assumed to be true by default.

    • Optional instanceId: string

      The Id of the Instance for which the distribution of components is being set. The Id of the current instance (Coordinator.instance) is used by default.

    Returns Promise<Instance>

    A Promise that once resolved contains the updated Instance.

setInstanceActiveness

  • setInstanceActiveness(active: Boolean): Promise<any>
  • Sets if the current Instance is active (i.e., the application using the Coordinator is actively being used).

    todo

    Change Promise to Promise by converting the objects before resolving the Promise.

    Parameters

    • active: Boolean

      It indicates whether the current Instance should be set as active or inactive.

    Returns Promise<any>

    A Promise that once resolved contains the updated instance as it was returned from the broker. It should however nearly match the structure of the Instance class. If an error occurs the Promise will be rejected.

setResourceData

  • setResourceData(data: any, id?: string): Promise<any>
  • Set the data contents of the Resource with the given Id.

    Parameters

    • data: any

      The data contents of that should be saved to the Resource.

    • Optional id: string

      The Id of the Resource that should have its data content replaced with the provided data. If the Id is not provided the Id of the currently selected Resource will be used by default.

    Returns Promise<any>

    A Promise that once resolved contains the data contents of the Resource. If an error occurs the Promise will be rejected.

shareResource

  • shareResource(userEmail: string, resourceId?: string): Promise<SharedResource>
  • Shares a Resource with a given Id with an User with a certain e-mail address.

    Parameters

    • userEmail: string

      The e-mail address of the user with whom the Resource with the given Id should be shared.

    • Optional resourceId: string

      The Id of the Resource that should be shared with the user with the provided e-mail address. If no Id is provided the Id of the currently subscribed to resource will be used (Coordinator.subscribedResourceId).

    Returns Promise<SharedResource>

    • A Promise that once resolved constains the resource that was shared in the form an instance of SharedResource class. If an error occurs the Promise will be rejected.

subscribeEvents

  • subscribeEvents(subscriberFunction: (data: any, eventType: string) => void): void
  • Subscribe to events fired by the User while running the same Client.

    todo
    • Add a type definition that encapsulates the event data.

    Parameters

    • subscriberFunction: (data: any, eventType: string) => void

      A function that receives a plain object with the information that is associated with the event and string with the type of the event.

        • (data: any, eventType: string): void
        • Parameters

          • data: any
          • eventType: string

          Returns void

    Returns void

subscribeInstances

  • subscribeInstances(subscriberFunction: (data: Instance, eventType: string) => void): void
  • Subscribe to changes made to the instances belonging to the current User, i.e., instances that become active/inactive or that suffer changes to the distribution of UI components.

    Parameters

    • subscriberFunction: (data: Instance, eventType: string) => void

      The function that gets called when an instance belonging to the currently logged in user User changes. The function receives an Instance object representing the instance that changed and the type of event (created, updated, patched or removed) that caused the change.

        • (data: Instance, eventType: string): void
        • Parameters

          Returns void

    Returns void

subscribeProxemics

  • subscribeProxemics(subscriberFunction: (data: Proxemics, eventType: string) => void): void
  • Subscribe to changes made to the proxemic relationships of the devices of the current User and possibly of other users that share access to the same subscribed resource.

    Parameters

    • subscriberFunction: (data: Proxemics, eventType: string) => void

      The function that gets called when the proxemic state of the currently logged in user User changes. The function receives an updated Proxemics object and the type of event (created, updated, patched or removed) that generated the change.

        • Parameters

          Returns void

    Returns void

subscribeReconnects

  • subscribeReconnects(subscriberFunction: (resourceData: any, proxemics: Proxemics, resourceId: string) => void): void
  • Subscribe to get reinitialization information from the Coordinator whenever the connection to the broker is reestablished after a disconnect.

    Parameters

    • subscriberFunction: (resourceData: any, proxemics: Proxemics, resourceId: string) => void

      A function that receives the data of default resource (Coordinator.resource), information about the proxemic state and the Id of the default resource.

        • (resourceData: any, proxemics: Proxemics, resourceId: string): void
        • Parameters

          • resourceData: any
          • proxemics: Proxemics
          • resourceId: string

          Returns void

    Returns void

subscribeResource

  • subscribeResource(subscriberFunction: (data: any, eventType: string) => void, resourceId?: string): Promise<any>
  • Subscribe to a Resource with a given Id by registering a function that is called whenever there are changes made to that Resource by clients connected to the broker. The Coordinator can only be subscribed to a resource. If it subscribes to another Resource, it will automatically call Coordinator.unsubscribeResource.

    todo

    Add a type definition to encapsulate the received data.

    Parameters

    • subscriberFunction: (data: any, eventType: string) => void

      The function that gets called when a change to the subscribed Resource is received. The function receives the resource data (Resource.data) and the type of event (created, updated, patched or removed) that generated the change.

        • (data: any, eventType: string): void
        • Parameters

          • data: any
          • eventType: string

          Returns void

    • Optional resourceId: string

      The Id of the Resource to subscribe to. If the Id is not provided the Id of the currently selected Resource will be used by default.

    Returns Promise<any>

subscribeResourceSubscription

  • subscribeResourceSubscription(subscriberFunction: (data: any, eventType: string) => void): void
  • Subscribe to changes made to the resource subscription, i.e., the information about which Resource is subscribed by the User.

    todo

    Add a ResourceSubscription class to encapsulate the data.

    Parameters

    • subscriberFunction: (data: any, eventType: string) => void

      The function that gets called when the resource that the currently logged in User is subscribed to changes. The function receives the resource subscription data directly from the broker and the type of event (created, updated, patched or removed) that generated the change.

        • (data: any, eventType: string): void
        • Parameters

          • data: any
          • eventType: string

          Returns void

    Returns void

subscribeResources

  • subscribeResources(subscriberFunction: (data: any, eventType: string) => void): void
  • Subscribe to changes to made to Resource that a user has access to (i.e., owned or shared with). TIP: This can be used to know when new resources are added/removed or shared/unshared.

    todo

    Add a type definition to encapsulate the received data.

    Parameters

    • subscriberFunction: (data: any, eventType: string) => void

      The function that gets called when a change to a Resource that user has access to is received. The function receives the resource data (Resource.data) and the type of event (created, updated, patched or removed) that generated the change.

        • (data: any, eventType: string): void
        • Parameters

          • data: any
          • eventType: string

          Returns void

    Returns void

unshareResource

  • unshareResource(userEmail: string, resourceId?: string): Promise<SharedResource>
  • Unshares a Resource with a given Id that was shared with a User with a certain e-mail address.

    Parameters

    • userEmail: string

      The e-mail address of the user with whom the Resource with the given Id should be unshared.

    • Optional resourceId: string

      The Id of the Resource that should be unshared with the user with the provided e-mail address. If no Id is provided the Id of the currently subscribed to resource will be used (Coordinator.subscribedResourceId).

    Returns Promise<SharedResource>

    • A Promise that once resolved constains the resource that was unshared in the form an instance of SharedResource class. If an error occurs the Promise will be rejected.

unsubscribeEvents

  • unsubscribeEvents(): void

unsubscribeInstances

  • unsubscribeInstances(): void

unsubscribeProxemics

  • unsubscribeProxemics(): void

unsubscribeReconnects

  • unsubscribeReconnects(): void

unsubscribeResource

  • unsubscribeResource(): void

unsubscribeResourceSubscription

  • unsubscribeResourceSubscription(): void
  • Unsubscribe from any changes made to the resource subscription of the current User.

    Returns void

unsubscribeResources

  • unsubscribeResources(): void

updateComponentsDistribution

updateInstanceActiveness

  • updateInstanceActiveness(): Promise<any>
  • Sets if the current Instance is active by automatically determining if the application instance using the Coordinator is actively being used by taking the value of "document.visibilityState" into consideration.

    todo

    Change Promise to Promise by converting the objects before resolving the Promise.

    Returns Promise<any>

    A Promise that once resolved contains the updated instance as it was returned from the broker. It should however nearly match the structure of the Instance class. If an error occurs the Promise will be rejected.

updateResources

Generated using TypeDoc