Options
All
  • Public
  • Public/Protected
  • All
Menu

Class FeathersCoordinator

Concrete implementation of the Coordinator interface that connects to the YanuX Broker using the Feathers Socket.io Client.

Hierarchy

  • FeathersCoordinator

Implements

Index

Constructors

constructor

  • new FeathersCoordinator(brokerUrl: string, localDeviceUrl?: string, clientId?: string, credentials?: Credentials, onAuthenticated?: (event: any) => void, onLogout?: (event: any) => void, onReAuthenticationError?: (event: any) => void, localStorageLocation?: string): FeathersCoordinator
  • Constructor that creates a ready to use FeathersCoordinator instance.

    Parameters

    • brokerUrl: string

      The URL of the broker that the FeathersCoordinator should connect to.

    • localDeviceUrl: string = 'http://localhost:3003'

      The URL of that exposes information about the local device (e.g., the Device UUID).

    • clientId: string = 'default'

      The Client Id used that identifies the application using this FeathersCoordinator instance

    • credentials: Credentials = null

      The authentication credentials used to identify the user and that authorize the access to their data.

    • onAuthenticated: (event: any) => void = ...

      A function that receives the name of the event and that is called when the connection to the broker is authenticated. A function that simply logs the event is provided by default.

        • (event: any): void
        • Parameters

          • event: any

          Returns void

    • onLogout: (event: any) => void = ...

      A function that receives the name of the event and that is called when the user logs out from the broker. A function that simply logs the event is provided by default.

        • (event: any): void
        • Parameters

          • event: any

          Returns void

    • onReAuthenticationError: (event: any) => void = ...

      A function that receives the name of the event and that is called when there is an erro reauthenticating the user. A function that simply logs the event is provided by default.

        • (event: any): void
        • Parameters

          • event: any

          Returns void

    • localStorageLocation: string = './data/localstorage'

      The path where to save the local storage data when running the FeathersCoordinator on Node.js.

    Returns FeathersCoordinator

Properties

Private _subscribedResourceId

_subscribedResourceId: string
todo

Document private property.

Private brokerUrl

brokerUrl: string
todo

Document private property.

Private cachedInstances

cachedInstances: Map<string, Instance>
todo

Document private property.

Private cachedProxemics

cachedProxemics: Map<string, Proxemics>
todo

Document private property.

Private cachedResources

cachedResources: Map<string, SharedResource>
todo

Document private property.

client

client: Client

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

Private credentials

credentials: Credentials
todo

Document private property.

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.

Private devicesService

devicesService: ServiceOverloads<any> & ServiceAddons<any> & ServiceMethods<any>
todo

Document private property.

Private eventsService

eventsService: ServiceOverloads<any> & ServiceAddons<any> & ServiceMethods<any>
todo

Document private property.

Private feathersClient

feathersClient: Application<object>
todo

Document private property.

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.

Private instancesService

instancesService: ServiceOverloads<any> & ServiceAddons<any> & ServiceMethods<any>
todo

Document private property.

Private localDeviceUrl

localDeviceUrl: string
todo

Document private property.

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.

Private proxemicsService

proxemicsService: ServiceOverloads<any> & ServiceAddons<any> & ServiceMethods<any>
todo

Document private property.

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.

Private resourceSubscriptionService

resourceSubscriptionService: ServiceOverloads<any> & ServiceAddons<any> & ServiceMethods<any>
todo

Document private property.

Private resourcesService

resourcesService: ServiceOverloads<any> & ServiceAddons<any> & ServiceMethods<any>
todo

Document private property.

Private socket

socket: Socket
todo

Document private property.

Private storage

storage: Storage
todo

Document private property.

Private subscribeEventsFunction

subscribeEventsFunction: (data: any, eventType: string) => void

Type declaration

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

      Document private property.

      Parameters

      • data: any
      • eventType: string

      Returns void

Private subscribeInstancesFunctions

subscribeInstancesFunctions: {}
todo

Document private property.

Type declaration

  • [eventType: string]: (resource: any) => void
      • (resource: any): void
      • Parameters

        • resource: any

        Returns void

Private subscribeProxemicsFunctions

subscribeProxemicsFunctions: {}
todo

Document private property.

Type declaration

  • [eventType: string]: (resource: any) => void
      • (resource: any): void
      • Parameters

        • resource: any

        Returns void

Private subscribeReconnectsFunction

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

Type declaration

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

      Document private property.

      Parameters

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

      Returns void

Private subscribeResourceFunctions

subscribeResourceFunctions: {}
todo

Document private property.

Type declaration

  • [eventType: string]: (resource: any) => void
      • (resource: any): void
      • Parameters

        • resource: any

        Returns void

Private subscribeResourceSubscriptionFunctions

subscribeResourceSubscriptionFunctions: {}
todo

Document private property.

Type declaration

  • [eventType: string]: (resource: any) => void
      • (resource: any): void
      • Parameters

        • resource: any

        Returns void

Private subscribeResourcesFunctions

subscribeResourcesFunctions: {}
todo

Document private property.

Type declaration

  • [eventType: string]: (resource: any) => void
      • (resource: any): void
      • Parameters

        • resource: any

        Returns void

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.

Private usersService

usersService: ServiceOverloads<any> & ServiceAddons<any> & ServiceMethods<any>
todo

Document private property.

Static Private GENERIC_EVENT_CALLBACK

GENERIC_EVENT_CALLBACK: (evenType: string) => (event: any) => void = ...

Type declaration

    • (evenType: string): (event: any) => void
    • Parameters

      • evenType: string

      Returns (event: any) => void

        • (event: any): void
        • Parameters

          • event: any

          Returns void

Static Private LOCAL_STORAGE_JWT_ACCESS_TOKEN_KEY

LOCAL_STORAGE_JWT_ACCESS_TOKEN_KEY: string = 'feathers-jwt'

Accessors

subscribedResourceId

  • get subscribedResourceId(): string

Methods

clearComponentsDistribution

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

createResource

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.

    Parameters

    • value: any
    • name: string

    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).

    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).

    Parameters

    • extraConditions: any

    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.

Private getProxemics

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.

Private getResource

  • getResource(resourceId?: string): Promise<Resource>

getResourceData

  • getResourceData(resourceId?: string): Promise<any>

Private getResourceSubscription

  • getResourceSubscription(): Promise<any>

getResources

  • getResources(owned?: boolean, sharedWith?: boolean): Promise<SharedResource[]>

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

renameResource

  • renameResource(name: string, resourceId?: string): Promise<SharedResource>

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
        • (data: any, eventType: string): void
        • Parameters

          • data: any
          • eventType: string

          Returns void

    • resourceId: string

    Returns Promise<any>

setComponentDistribution

  • setComponentDistribution(components: {}, auto?: Boolean, instanceId?: string): Promise<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).

    Parameters

    • active: Boolean

    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, resourceId?: string): Promise<any>

shareResource

  • shareResource(userEmail: string, resourceId?: string): Promise<SharedResource>

subscribeEvents

  • subscribeEvents(subscriberFunction: (data: any, eventType: string) => void): 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
        • (data: Instance, eventType: string): void
        • Parameters

          Returns void

    Returns void

subscribeProxemics

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

subscribeReconnects

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

subscribeResource

  • subscribeResource(subscriberFunction: (data: any, eventType: string) => void, resourceId?: string): Promise<any>

subscribeResourceSubscription

  • subscribeResourceSubscription(subscriberFunction: (data: any, eventType: string) => void): 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.

    Parameters

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

          • data: any
          • eventType: string

          Returns void

    Returns void

Private subscribeService

  • subscribeService(service: ServiceOverloads<any> & ServiceAddons<any> & ServiceMethods<any>, subscribeFunctions: {}): void
  • todo

    Document private method.

    Parameters

    • service: ServiceOverloads<any> & ServiceAddons<any> & ServiceMethods<any>
    • subscribeFunctions: {}
      • [eventType: string]: (entity: any) => void
          • (entity: any): void
          • Parameters

            • entity: any

            Returns void

    Returns void

unshareResource

  • unshareResource(userEmail: string, resourceId?: string): Promise<SharedResource>

unsubscribeEvents

  • unsubscribeEvents(): void

unsubscribeInstances

  • unsubscribeInstances(): void

unsubscribeProxemics

  • unsubscribeProxemics(): void

unsubscribeReconnects

  • unsubscribeReconnects(): void

unsubscribeResource

  • unsubscribeResource(): void

unsubscribeResourceSubscription

  • unsubscribeResourceSubscription(): void

unsubscribeResources

  • unsubscribeResources(): void

Private unsubscribeService

  • unsubscribeService(service: ServiceOverloads<any> & ServiceAddons<any> & ServiceMethods<any>, subscribeFunctions: {}): void
  • todo

    Document private method.

    Parameters

    • service: ServiceOverloads<any> & ServiceAddons<any> & ServiceMethods<any>
    • subscribeFunctions: {}
      • [eventType: string]: (entity: any) => void
          • (entity: any): void
          • Parameters

            • entity: any

            Returns void

    Returns void

updateComponentsDistribution

Private updateDynamicSharing

  • updateDynamicSharing(r?: Resource): Promise<any>

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.

    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.

Private updateResource

  • updateResource(resource: any): void

Private updateResourceSubscription

  • updateResourceSubscription(): Promise<any>

updateResources

Static Private cacheCleanup

  • cacheCleanup(cache: Map<string, BaseEntity>, maxCacheSize?: number, maxCacheAge?: number): void

Generated using TypeDoc