API Docs for: 2.0.0

Class SAGE2_App

Class defined in: public/src/SAGE2_App.js:27

Constructor for SAGE2 applications

addToAppsLaunchedList( data )
public/src/SAGE2_App.js:1176

Asks server to launch app with values. On the server this will add additional associations like which app launched which. Part of the launch process will include calling back to this app and stating the id of the newly launched app.

Parameters:
  • data <String>
    • name of app to launch. Has to correctly match.
applicationRPC( query, funcName, broadcast )
public/src/SAGE2_App.js:875

Support for the RPC call to the server

Parameters:
  • query <Object>

    parameter for RPC function on server

  • funcName <String>

    return function name for broadcast or emit

  • broadcast <Boolean>

    wether or not doing a return broadcast or emit

broadcast( funcName, data )
public/src/SAGE2_App.js:864

RPC to every application client (client-side)

Parameters:
  • funcName <String>

    name of the function to be called in each client

  • data <Object>

    parameters to the function call

callback( func, data )
public/src/SAGE2_App.js:887

Entry point for a RPC callback into the app. Needed to keep state consistant

Parameters:
  • func <Function>

    actual method to call

  • data <Object>

    parameters sent from server

close( )
public/src/SAGE2_App.js:819

Close the application itself

createLayer( backgroundColor )
public/src/SAGE2_App.js:583

Method to create a layered div ontop the application

Parameters:
  • backgroundColor <String>

    color in DOM-syntax for the div

getCallbackName( callback )
public/src/SAGE2_App.js:1204

Given a function, will attempt to determine the string name.

Parameters:
  • callback <Function>
    • The function to get name as a string.
getFullContextMenuAndUpdate( )
public/src/SAGE2_App.js:980

Performs full fill of app context menu and sends update to server. This provides one place(mostly) to change code for context menu.

hideLayer( )
public/src/SAGE2_App.js:625

Method to hide the layer

Boolean isHidden( )
public/src/SAGE2_App.js:664

Calculate if the application is hidden in this display


Returns: <Boolean>

Returns true if out of screen

Bool isLayerHidden( )
public/src/SAGE2_App.js:651

Method returning the visibility of the layer


Returns: <Bool>

true if layer is hidden

isSharedWithRemoteSite( )
public/src/SAGE2_App.js:353

Used to check if display believes this app is shared with a remote site. This is done by checking if the sync icon is visible.

Boolean isVisible( )
public/src/SAGE2_App.js:689

Calculate if the application is visible in this display


Returns: <Boolean>

Returns true if visible

launchAppWithValues( appName, paramObj, x, y, funcToPassParams )
public/src/SAGE2_App.js:1123

Asks server to launch app with values. On the server this will add additional associations like which app launched which. Part of the launch process will include calling back to this app and stating the id of the newly launched app.

Parameters:
  • appName <String>
    • name of app to launch. Has to correctly match.
  • paramObj <Object>
    • optional. What to pass the launched app. Appears within init() as serverDataInitValues.
  • x <Integer | Undefined | Null>
    • optional. X coordinate to start the app at.
  • y <Integer | Undefined | Null>

    -optional. Y coordinate to start the app at.

  • funcToPassParams <String | Undefined | Null>
    • optional. app which called this function. Could be a function and will convert to string.
loadSavedData( filename, callback )
public/src/SAGE2_App.js:1085

Loads a saved data file (from the saveFile function)

Parameters:
  • filename <String>

    The filename to load

  • callback <Function>

    function to call when loading is done

log( msg )
public/src/SAGE2_App.js:923

Prints message to local browser console and send to server. Accept a string as parameter or multiple parameters

Parameters:
  • msg <Object>

    list of arguments to be printed

postDraw( date )
public/src/SAGE2_App.js:740

Method called after the draw function

Parameters:
  • date <Date>

    current time from the server

preDraw( date )
public/src/SAGE2_App.js:699

Method called before the draw function, calculates timing and frame rate

Parameters:
  • date <Date>

    current time from the server

refresh( date )
public/src/SAGE2_App.js:765

Internal method for an actual draw loop (predraw, draw, postdraw). draw is called as needed

Parameters:
  • date <Date>

    current time from the server

registerFileListHandler( mth )
public/src/SAGE2_App.js:903

Register a callback to be called when receiving a updated file list from server

Parameters:
  • mth <Method>

    method on object to be called back

requestFileBuffer( fileName )
public/src/SAGE2_App.js:943

Application request for fileBuffer

Parameters:
  • fileName <String>

    name of the file to which data will be saved.

requestNewTitle( newTitle )
public/src/SAGE2_App.js:964

Application request for a new title

Parameters:
  • newTitle <String>

    Text that will be set as the new title for this instance of the app.

SAGE2CopyState( state )
public/src/SAGE2_App.js:378

SAGE2CopyState method called on init or load to copy state of app instance

Parameters:
  • state <Object>

    contains state of app instance

SAGE2Init( type, data )
public/src/SAGE2_App.js:89

SAGE2Init method called right after the constructor

Parameters:
  • type <String>

    type of DOM element to be created (div, canvas, ...)

  • data <Object>

    contains initialization values (id, width, height, state, ...)

saveFile( filename, ext, data )
public/src/SAGE2_App.js:1098

Uses WebSocket to send a request to the server to save a file from the app into the media folders as an asset (image, pdf, ...)

Parameters:
  • filename <String>

    The name for the file being saved

  • ext <String>

    The file's extension

  • data <String>

    The file's data

saveFile( subdir, filename, ext, data )
public/src/SAGE2_App.js:1057

Uses WebSocket to send a request to the server to save a file from the app into the media folders. The file will be placed in a subdirectory of the media folders called savedFiles/appname/(subdir)?/ . The file name must not contains any directory characters ('/', '', etc.).

Parameters:
  • subdir <String>

    Subdirectory within the app's folder to save file

  • filename <String>

    The name for the file being saved

  • ext <String>

    The file's extension

  • data <String>

    The file's data

sendDataToChildrenApps( func, data )
public/src/SAGE2_App.js:1148

Sends data to any apps that this one launched. This doesn't go through server.

Parameters:
  • func <String>
    • name of function to activate. Has to correctly match
  • data <Object>
    • data to send. doens't have to be an object.
sendDataToClient( clientDest, func, paramObj )
public/src/SAGE2_App.js:1187

This is used to send data to a specific SAGE2 client. Usually UI clients.

Parameters:
  • clientDest <String>
    • Which client to send the data.
  • func <String>
    • What function to call on the client.
  • paramObj <Object>
    • Object to give the function as parameter. This will have clientDest, func, and appId added.
sendDataToParentApp( func, data )
public/src/SAGE2_App.js:1163

Sends data to app that launched this one if possible. This doesn't go through server.

Parameters:
  • func <String>
    • name of function to activate. Has to correctly match.
  • data <Object>
    • data to send. doens't have to be an object.
sendFullscreen( )
public/src/SAGE2_App.js:848

Request fullscreen

sendResize( newWidth, newHeight )
public/src/SAGE2_App.js:829

Application request for a new size

Parameters:
  • newWidth <Number>

    desired width

  • newHeight <Number>

    desired height

serverDataBroadcastDestination( nameSuffix, value, description, callback )
public/src/SAGE2_App.js:1322

Helper function to tell server about a destination. In addition to creating the variable on the server, will also subscribe to the variable. Name will be of format: app_id:destination:givenName

Parameters:
  • nameSuffix <String>
    • name suffix
  • value <Object>
    • the initial value. Probably is blank.
  • description <Object>
    • description object
  • callback <String>
    • what function will handle values given to the source
serverDataBroadcastSource( nameSuffix, value, description )
public/src/SAGE2_App.js:1302

Helper function to tell server about a source. This will add additional markers to the variable. Name will be of format: app_id:source:givenName

Parameters:
  • nameSuffix <String>
    • name suffix
  • value <Object>
    • the value to store for this variable
  • description <Object>
    • description object
serverDataGetAllTrackedDescriptions( callback, unsubscribe )
public/src/SAGE2_App.js:1395

Asks server for all variable names and their descriptions. Goes to callback as array. Contents of the array will be objects with two properties: nameOfValue and description.

Parameters:
  • callback <String>
    • app which called this function. Could be a function and will convert to string.
  • unsubscribe <Boolean>
    • optional. If true, will stop receiving updates for that variable.
serverDataGetValue( nameOfValue, callback )
public/src/SAGE2_App.js:1232

Given the name of the variable, will ask server for the variable. The given callback will be activated with that variable's value. Current setup will not activate callback if there is no variable.

Parameters:
  • nameOfValue <String>
    • which value to get
  • callback <String>
    • function on app to give value. Could be a function ref and will convert to string.
serverDataRemoveAllValuesGivenToServer( )
public/src/SAGE2_App.js:1433

Will remove all source and destination variables submitted to server. Expectation is this is not called by user (but the option is there) instead as part of cleanup on quit().

serverDataRemoveValue( namesOfValuesToRemove )
public/src/SAGE2_App.js:1416

Given the name of the variable, remove variable from server. Expectation is this is not called by user (but the option is there) instead as part of cleanup on quit(). Sends an array of strings, which this function is just the specified value.

Parameters:
  • namesOfValuesToRemove <String | Array>
    • Can give a single name as string, or an array of string to remove.
serverDataSetSourceValue( nameSuffix, value, description, shouldRemoveValueFromServerWhenAppCloses )
public/src/SAGE2_App.js:1279

Helper function, given the variable name suffix, set value of variable on server. Checks in place to ensure value exists.

Parameters:
  • nameSuffix <String>
    • name of value on server to set
  • value <Object>
    • the value to store for this variable
  • description <Object>
    • description object
  • shouldRemoveValueFromServerWhenAppCloses <Boolean>
    • Optional. If true, app quit will remove value from server.
serverDataSetValue( nameOfValue, value, description, shouldRemoveValueFromServerWhenAppCloses )
public/src/SAGE2_App.js:1255

Given the name of the variable, set value of variable on server. Will create if doesn't exist.

Parameters:
  • nameOfValue <String>
    • name of value on server to set
  • value <Object>
    • the value to store for this variable
  • description <Object>
    • description object
  • shouldRemoveValueFromServerWhenAppCloses <Boolean>
    • Optional. If true, app quit will remove value from server.
serverDataSubscribeToNewValueNotification( callback, unsubscribe )
public/src/SAGE2_App.js:1371

Asks server for notifications of any new variables that are added to server. The callback will get one object with properties: nameOfValue and description.

Parameters:
  • callback <String>
    • app which called this function. Could be a function and will convert to string.
  • unsubscribe <Boolean>
    • optional. If true, will stop receiving notificaitons.
serverDataSubscribeToValue( nameOfValue, callback, unsubscribe )
public/src/SAGE2_App.js:1347

Given the name of a variable, will ask server to send its value each time it is assigned. Values will be sent to callback.

Parameters:
  • nameOfValue <String>
    • app which called this function
  • callback <String>
    • app which called this function. Could be a function and will convert to string.
  • unsubscribe <Boolean>
    • optional. If true, will stop receiving updates for that variable.
showHideLayer( )
public/src/SAGE2_App.js:636

Method to flip the visibility of the layer

showLayer( )
public/src/SAGE2_App.js:609

Method to display the layer

terminate( )
public/src/SAGE2_App.js:801

Method called by SAGE2, and calls the application 'quit' method

toggleRemotePointerEventPassing( )
public/src/SAGE2_App.js:369

Used to set status of event sharing. Activated through context menu.

unregisterFileListHandler( mth )
public/src/SAGE2_App.js:913

Unregister a callback to be called when receiving a updated file list from server

Parameters:
  • mth <Method>

    method on object to be called back

updateTitle( title )
public/src/SAGE2_App.js:751

Change the title of the application window

Parameters:
  • title <String>

    new title string