fsEventsHEventCall
The fsEventsHEventCall function can be used to call an H event. Note that all parameters are converted to strings before being sent, therefor ensure that complex data has been correctly formatted before sending.
Syntax
FsEventsError fsEventsHEventCall(
FsHEventId id,
FsVarParamArray param
);
Parameters
| Parameters | Description |
|---|---|
eventId |
The ID of the H event, as returned by the |
param |
The array of parameters that must be sent to the H event. Array's values can be Integer, String, CRC, Double, or Vec3d. |
Return Values
The function will return an FsEventsError code, or FS_EVENTS_ERROR_NONE if it succeeded.
Example
In this example, one of the VCockpits made using JavaScript will listen for an H Event: H:MyHEvent. On the WebAssembly side, FsHEventId myHEvent has been registered with fsEventsRegisterHEvent. , and the event requires a Vec3d as an argument. This means you can call this H Event with the following:
Vec3d v {1, 2, 3};
FsVarParamVariant param;
param.type = FsVarParamTypeVec3d;
param.vec3dValue = v;
FsVarParamArray paramArray;
paramArray.size = 1;
paramArray.array = ¶m;
FsEventsError errorCode = fsEventsHEventCall(myHEvent, paramArray);
if (errorCode != FS_EVENTS_ERROR_NONE)
{
fprintf(stderr, "An error occurs when calling myHEvent: %d", errorCode);
}
Now, in all JavaScript VCockpit, the callback OnInteractionEvent will be called with ["MyHEvent", "[1.00, 2.00, 3.00]"]:
onInteractionEvent(evt) {
if (evt[0] == "MyHEvent") {
// MyHEvent has been received
// params are in evt[1]
}
}
Related Topics