Options
All
  • Public
  • Public/Protected
  • All
Menu

Class BaseService

Services are processes that run in the background and are waken up in certain circumstances such as by global events or user interactions.

Each service takes an entry in the system tray menu located on the system panel. This menu entry is used to access to service visual contents such as: options, task performing based on user interaction, etc.

Services are singleton processes, there is only one process of a service at a time

export
abstract

Hierarchy

Index

Constructors

constructor

Properties

Protected _api

_api: typeof API

Reference to the core API namespace

memberof

BaseModel

Protected _gui

_gui: typeof GUI

Reference to the core GUI namespace

memberof

BaseModel

Protected _observable

_observable: Announcer

Each model has its own local announcement system to handle all local events inside that model.

This observable object is propagate to all the UI elements (AFXTag) inside the model

memberof

BaseModel

args

The argument of the model

memberof

BaseModel

birth

birth: number

Placeholder for the process creation timestamp

memberof

BaseModel

dialog

dialog: BaseDialog

Reference to the model's dialog

memberof

BaseModel

domel

Reference to the menu entry DOM element attached to the service

memberof

BaseService

holder

holder: HTMLElement

Reference to the system tray menu

memberof

BaseService

Protected host

host: string

The HTML element ID of the virtual desktop

memberof

BaseModel

icon

icon: string

The service icon shown in the system tray

memberof

BaseService

iconclass

iconclass: string

CSS class of the service icon shown in the system tray

memberof

BaseService

name

name: string

The class name

memberof

BaseModel

onmenuselect

onmenuselect: (d: TagEventType<MenuEventData>) => void

Placeholder for service select callback

memberof

BaseService

Type declaration

pid

pid: number

The process number of the current model. For sub-window this number is the number of the parent window

memberof

BaseModel

scheme

scheme: HTMLElement

Reference the DOM element of the UI scheme belong to this model

memberof

BaseModel

Protected systemsetting

systemsetting: typeof setting

Reference to the system setting

memberof

BaseModel

text

text: string

Text of the service shown in the system tray

memberof

BaseService

Private timer

timer: number

Reference to the timer that periodically executes the callback defined in watch.

memberof

BaseService

Static dependencies

dependencies: string[]

The javascript or css files that the model depends on. All dependencies will be loaded before the model is rendered

static
memberof

BaseModel

Static meta

Place holder for model meta-data

static
memberof

BaseModel

Static singleton

singleton: boolean

Allow singleton on this model

static
memberof

BaseModel

Static style

style: HTMLElement | string

Reference to the CSS Element of the model

static
memberof

BaseModel

Static type

type: ModelType

Different model type

static
memberof

BaseModel

Accessors

observable

Methods

Protected ask

attach

Abstract awake

  • Awake the service, this function is usually called when the system tray menu entry attached to the service is selected.

    This function should be implemented by all subclasses

    abstract
    memberof

    BaseService

    Parameters

    Returns void

Protected call

  • Execute a server side script and get back the result

    memberof

    BaseModel

    Parameters

    • cmd: GenericObject<any>

      execution indication, should be:

      {
           path?: string, // VFS path to the server side script
           code: string, // or server side code to be executed
           parameters: any // the parameters of the server side execution
      }
      

    Returns Promise<any>

Protected cleanup

error

fail

  • fail(m: string, e?: Error): void

Protected find

hide

  • hide(): void

Abstract init

  • init(): void
  • Init the service before attaching it to the system tray: event subscribe, scheme loading.

    Should be implemented by all subclasses

    abstract
    memberof

    BaseService

    Returns void

main

  • main(): void

meta

notify

Protected off

  • off(e: string, f?: (d: any) => void): void
  • Unsubscribe an event

    memberof

    BaseModel

    Parameters

    • e: string

      event name or * (all events)

    • Optional f: (d: any) => void
        • (d: any): void
        • Parameters

          • d: any

          Returns void

    Returns void

Protected on

  • on(e: string, f: (d: any) => void): void
  • Subscribe to a local event

    memberof

    BaseModel

    Parameters

    • e: string

      event name

    • f: (d: any) => void

      event callback

        • (d: any): void
        • Parameters

          • d: any

          Returns void

    Returns void

Protected one

  • one(e: string, f: (d: any) => void): void
  • subscribe once to a local event

    memberof

    BaseModel

    Parameters

    • e: string

      name of the event

    • f: (d: any) => void

      event callback

        • (d: any): void
        • Parameters

          • d: any

          Returns void

    Returns void

Protected onexit

openDialog

path

  • path(): string

Protected publish

quit

  • quit(force: boolean): void

Protected render

  • render(p: string): void

Protected select

show

  • show(): void

Protected stream

  • stream(): Promise<WebSocket>
  • Connect to the server side api using a websocket connection

    Server side script can be execute inside the stream by writing data in JSON format with the following interface

    {
         path?: string, // VFS path to the server side script
         code: string, // or server side code to be executed
         parameters: any // the parameters of the server side execution
    }
    
    memberof

    BaseModel

    Returns Promise<WebSocket>

Protected subscribe

  • subscribe(e: string, f: (d: any) => void): void
  • subscribe to an event on the global announcement system

    memberof

    BaseModel

    Parameters

    • e: string

      event name

    • f: (d: any) => void

      event callback

        • (d: any): void
        • Parameters

          • d: any

          Returns void

    Returns void

throwe

  • throwe(): Error

Protected trigger

  • trigger(e: string, d?: any): void

update

  • update(): void

Protected updateLocale

  • updateLocale(name: string): void

warn

Protected watch

  • watch(t: number, f: () => void): number
  • Set the callback that will be called periodically after a period of time.

    Each service should only have at most one watcher

    memberof

    BaseService

    Parameters

    • t: number

      period time in seconds

    • f: () => void

      callback function

        • (): void
        • Returns void

    Returns number