Flow API
The functions here are designed to warn add-on packages about the different states of the simulation flow and the potential FLT files that are loaded. The Flow API is a "global" API that is mainly used to deal with Back On Track events, and it is available across the following platforms:
You can find a sample project to use as a reference when using the Flow API here:
There are also debugging tools available in DevMode which can be used to help debug Flow Events and API events, which is described on the following page:
Using The Flow API
To receive flow event from the simulation, you must follow the steps outlined below:
- Register the listener in the JavaScript code:
this.platformDispatcherListener = RegisterViewListener('JS_LISTENER_COMM_BUS'); // or this.platformDispatcherListener = RegisterCommBusListener(() => { ... }); - Create a callback which will be used when a flow event is received:
The data string that is sent requires the following two data-points:ReceiveEvent(dataStr) { var data = JSON.parse(dataStr); // dataStr is a json which respects the format : // { "event" : id_of_the_event, "flt_path" : "path_of_the_flt" } }
Parameters Description id_of_the_eventThe id of a flow event that follows the enum defined in FsFlowEvent. path_of_the_fltThe VFS path of a potential FLT file loaded with the event received. - Finally you need to register the corresponding
__FLOW_API__to call the callback on Event:this.platformDispatcherListener.on("__FLOW_API__", this.ReceiveEvent);