Tilde Friends
Tilde Friends Core JS

Functions

function printError (error)
 
function invoke (handlers, argv)
 
function broadcastEvent (eventName, argv)
 
function broadcast (message)
 
function broadcastAppEventToUser (user, packageOwner, packageName, eventName, argv)
 
function getUser (caller, process)
 
function postMessageInternal (from, to, message)
 
function async getProcessBlob (blobId, key, options)
 
ssb addEventListener ('message', function() { broadcastEvent('onMessage', [...arguments]);})
 
function async loadSettings ()
 
function sendStats ()
 

Variables

let gProcesses = {}
 
let gStatsTimer = false
 
let g_handler_index = 0
 
const k_ping_interval = 60 * 1000
 
exports callAppHandler
 

Detailed Description

Tilde Friends process management, in JavaScript.

Function Documentation

◆ broadcast()

function broadcast (   message)

Send a message to all other instances of the same app.

Parameters
messageThe message.
Returns
A promise.

◆ broadcastAppEventToUser()

function broadcastAppEventToUser (   user,
  packageOwner,
  packageName,
  eventName,
  argv 
)

Send a message to all instances of the same app running as the same user.

Parameters
userThe user.
packageOwnerThe owner of the app.
packageNameThe name of the app.
eventNameThe name of the event.
argvThe arguments to pass.
Returns
A promise.

◆ broadcastEvent()

function broadcastEvent (   eventName,
  argv 
)

Broadcast a named event to all registered apps.

Parameters
eventNamethe name of the event.
argvArguments to pass to the handlers.
Returns
A promise.

◆ getProcessBlob()

function async getProcessBlob (   blobId,
  key,
  options 
)

Get or create a process for an app blob.

Parameters
blobIdThe blob identifier.
keyA unique key for the invocation.
optionsOther options.
Returns
The process.

◆ getUser()

function getUser (   caller,
  process 
)

Get user context information for a call.

Parameters
callerThe calling process.
processThe receiving process.

◆ invoke()

function invoke (   handlers,
  argv 
)

Invoke a handler.

Parameters
handlersThe handlers on which to invoke the callback.
argvArguments to pass to the handlers.
Returns
A promise.

◆ loadSettings()

function async loadSettings ( )

Load settings from the database.

Returns
The settings as a key value pairs object.

◆ postMessageInternal()

function postMessageInternal (   from,
  to,
  message 
)

Send a message.

Parameters
fromThe calling process.
toThe receiving process.
messageThe message.
Returns
A promise.

◆ printError()

function printError (   error)

Print an error.

Parameters
errorThe error.

◆ sendStats()

function sendStats ( )

Send periodic stats to all clients.

Variable Documentation

◆ callAppHandler

exports callAppHandler

Invoke an app's handler.js.

Parameters
responseThe response object.
app_blob_idThe app's blob identifier.
pathThe request path.
queryThe request query string.
headersThe request headers.
package_ownerThe app's owner.
package_nameThe app's name.

◆ g_handler_index

let g_handler_index = 0

Effectively a process ID.

◆ gProcesses

let gProcesses = {}

All running processes.

◆ gStatsTimer

let gStatsTimer = false

Whether stats are currently being sent.

◆ k_ping_interval

const k_ping_interval = 60 * 1000

Time between pings, in milliseconds.