7#include <node_buffer.h>
16#include "EngagePlatformNotifications.h"
23#define ENGAGE_BINDING(_nm) \
25 New<String>(#_nm).ToLocalChecked(), \
26 GetFunction(New<FunctionTemplate>(_nm)).ToLocalChecked());
29#define STRVAL(_infoIndex) \
30 *Nan::Utf8String(info[_infoIndex]->ToString(Nan::GetCurrentContext()).FromMaybe(v8::Local<v8::String>()))
33#define INTVAL(_index) \
34 info[_index]->Int32Value(Nan::GetCurrentContext()).FromJust()
37#define NANRETI(_expr) \
38 info.GetReturnValue().Set(_expr);
41#define NANRETS(_expr) \
42 info.GetReturnValue().Set(New(_expr).ToLocalChecked());
45#define ENGAGE_CB_NO_PARAMS(_ename) \
46 void on_ ## _ename(const char *eventExtraJson) \
48 CrossThreadCallbackWorker *cbw = getCallback(#_ename); \
53 cbw->enqueue(eventExtraJson); \
54 cbw->RELEASE_OBJECT_REFERENCE(); \
58#define ENGAGE_CB_STR_PARAM(_ename) \
59 void on_ ## _ename(const char *str, const char *eventExtraJson) \
61 CrossThreadCallbackWorker *cbw = getCallback(#_ename); \
66 cbw->enqueue(str, eventExtraJson); \
67 cbw->RELEASE_OBJECT_REFERENCE(); \
71#define ENGAGE_CB_ID_PARAM(_ename) \
72 void on_ ## _ename(const char *id, const char *eventExtraJson) \
74 CrossThreadCallbackWorker *cbw = getCallback(#_ename); \
79 cbw->enqueue(id, eventExtraJson); \
80 cbw->RELEASE_OBJECT_REFERENCE(); \
84#define ENGAGE_CB_ID_PLUS_ONE_STRING_PARAM(_ename) \
85 void on_ ## _ename(const char *id, const char *s, const char *eventExtraJson) \
87 CrossThreadCallbackWorker *cbw = getCallback(#_ename); \
92 cbw->enqueue(id, s, eventExtraJson); \
93 cbw->RELEASE_OBJECT_REFERENCE(); \
97#define ENGAGE_CB_TABLE_ENTRY(_pfn, _ename) \
98 g_eventCallbacks._pfn = on_ ## _ename;
110 typedef enum {ptString, ptInt, ptStringVector} Type_t;
121 if(s !=
nullptr && s[0] != 0)
147 _type = ptStringVector;
153 while(array[index] !=
nullptr)
155 _val.push_back(array[index] !=
nullptr ? array[index] :
"");
161 std::vector<std::string> _val;
166 Nan::HandleScope scope;
169 _evLoop = GetCurrentEventLoop();
174 _workCtx.data =
this;
180 v8::Local<v8::Object> obj = New<v8::Object>();
181 _persistentHandle.Reset(obj);
182 _resource =
new AsyncResource(
"CrossThreadCallbackWorker", obj);
184 ADD_OBJECT_REFERENCE();
189 Nan::HandleScope scope;
191 if (!_persistentHandle.IsEmpty())
193 _persistentHandle.Reset();
199 void ADD_OBJECT_REFERENCE()
201 assert(_refCount >= 0);
205 void RELEASE_OBJECT_REFERENCE()
207 assert(_refCount > 0);
208 if(_refCount.fetch_sub(1) == 1)
214 void enqueue(
const char *extra)
216 std::vector<Parameter*> *params =
new std::vector<Parameter*>();
217 params->push_back(
new StringParameter(extra));
221 void enqueue(
const char *s,
const char *extra)
223 std::vector<Parameter*> *params =
new std::vector<Parameter*>();
224 params->push_back(
new StringParameter(s));
225 params->push_back(
new StringParameter(extra));
229 void enqueue(
const char *s1,
const char *s2,
const char *extra)
231 std::vector<Parameter*> *params =
new std::vector<Parameter*>();
232 params->push_back(
new StringParameter(s1));
233 params->push_back(
new StringParameter(s2));
234 params->push_back(
new StringParameter(extra));
238 void enqueue(std::vector<Parameter*> *parameters)
249 std::this_thread::sleep_for(std::chrono::milliseconds(1));
254 _pendingParameters = parameters;
260 ADD_OBJECT_REFERENCE();
261 uv_queue_work(_evLoop,
263 CrossThreadCallbackWorker::onExecuteWork,
264 reinterpret_cast<uv_after_work_cb
>(CrossThreadCallbackWorker::onWorkCompleted));
267 static void onExecuteWork(uv_work_t* workCtx)
273 static void onWorkCompleted(uv_work_t* workCtx)
282 void internal_onWorkCompleted()
287 Nan::HandleScope scope;
289 v8::Isolate *isolate = v8::Isolate::GetCurrent();
290 v8::Local<Context> context = v8::Context::New(isolate);
293 if(_pendingParameters ==
nullptr || _pendingParameters->size() == 0)
295 _cb.Call(0,
nullptr, _resource);
301 v8::Local<v8::Value> *argv =
new v8::Local<v8::Value>[_pendingParameters->size()];
304 for(std::vector<Parameter*>::iterator itr = _pendingParameters->begin();
305 itr != _pendingParameters->end();
308 if((*itr)->_type == Parameter::ptString)
310 argv[index] = Nan::New<v8::String>(((StringParameter*)(*itr))->_val).ToLocalChecked();
312 else if((*itr)->_type == Parameter::ptStringVector)
314 StringVectorParameter *svp = (StringVectorParameter*)(*itr);
315 v8::Local<v8::Array> jsArray = Nan::New<v8::Array>(svp->_val.size());
317 int speakerIndex = 0;
318 for(std::vector<std::string>::iterator itrSpeakers = svp->_val.begin();
319 itrSpeakers != svp->_val.end();
323 #pragma GCC diagnostic push
324 #pragma GCC diagnostic ignored "-Wunused-result"
327 jsArray->Set(context, speakerIndex, v8::String::NewFromUtf8(isolate, itrSpeakers->c_str(), NewStringType::kNormal).ToLocalChecked());
330 #pragma GCC diagnostic pop
336 argv[index] = jsArray;
338 else if((*itr)->_type == Parameter::ptInt)
340 argv[index] = Nan::New<v8::Integer>(((IntParameter*)(*itr))->_val);
347 _cb.Call(_pendingParameters->size(), argv, _resource);
350 if(_pendingParameters !=
nullptr)
352 for(std::vector<Parameter*>::iterator itr = _pendingParameters->begin();
353 itr != _pendingParameters->end();
359 _pendingParameters->clear();
360 delete _pendingParameters;
361 _pendingParameters =
nullptr;
373 RELEASE_OBJECT_REFERENCE();
381 Nan::Persistent<v8::Object> _persistentHandle;
382 AsyncResource *_resource;
383 std::atomic<int> _refCount;
384 std::vector<Parameter*> *_pendingParameters;
387typedef std::map<std::string, CrossThreadCallbackWorker*> CallbackMap_t;
390static bool g_wantCallbacks =
true;
391static CallbackMap_t g_cbMap;
392static std::mutex g_cbMapLock;
393static std::string g_loggingHookFn;
408 CallbackMap_t::iterator itr = g_cbMap.find(cbName);
409 if(itr != g_cbMap.end())
412 rc->ADD_OBJECT_REFERENCE();
415 g_cbMapLock.unlock();
426ENGAGE_CB_NO_PARAMS(engineStarted)
427ENGAGE_CB_NO_PARAMS(engineStopped)
428ENGAGE_CB_NO_PARAMS(engineAudioDevicesRefreshed)
430ENGAGE_CB_ID_PARAM(rpPausingConnectionAttempt)
431ENGAGE_CB_ID_PARAM(rpConnecting)
432ENGAGE_CB_ID_PARAM(rpConnected)
433ENGAGE_CB_ID_PARAM(rpDisconnected)
434void on_rpRoundtripReport(
const char *
id, uint32_t rtMs, uint32_t rtQualityRating,
const char * eventExtraJson)
442 std::vector<CrossThreadCallbackWorker::Parameter*> *params =
new std::vector<CrossThreadCallbackWorker::Parameter*>();
447 cbw->enqueue(params);
449 cbw->RELEASE_OBJECT_REFERENCE();
452ENGAGE_CB_ID_PARAM(groupCreated)
453ENGAGE_CB_ID_PARAM(groupCreateFailed)
454ENGAGE_CB_ID_PARAM(groupDeleted)
456ENGAGE_CB_ID_PARAM(groupConnected)
457ENGAGE_CB_ID_PARAM(groupConnectFailed)
458ENGAGE_CB_ID_PARAM(groupDisconnected)
460ENGAGE_CB_ID_PARAM(groupJoined)
461ENGAGE_CB_ID_PARAM(groupJoinFailed)
462ENGAGE_CB_ID_PARAM(groupLeft)
464ENGAGE_CB_ID_PARAM(groupRxStarted)
465ENGAGE_CB_ID_PARAM(groupRxEnded)
467ENGAGE_CB_ID_PARAM(groupRxMuted)
468ENGAGE_CB_ID_PARAM(groupRxUnmuted)
469ENGAGE_CB_ID_PLUS_ONE_STRING_PARAM(groupRxSpeakersChanged)
471ENGAGE_CB_ID_PLUS_ONE_STRING_PARAM(groupNodeDiscovered)
472ENGAGE_CB_ID_PLUS_ONE_STRING_PARAM(groupNodeRediscovered)
473ENGAGE_CB_ID_PLUS_ONE_STRING_PARAM(groupNodeUndiscovered)
475ENGAGE_CB_ID_PARAM(groupTxStarted);
476ENGAGE_CB_ID_PARAM(groupTxEnded);
477ENGAGE_CB_ID_PARAM(groupTxFailed);
478ENGAGE_CB_ID_PARAM(groupTxUsurpedByPriority);
479ENGAGE_CB_ID_PARAM(groupMaxTxTimeExceeded);
481ENGAGE_CB_ID_PARAM(groupTxMuted)
482ENGAGE_CB_ID_PARAM(groupTxUnmuted)
484ENGAGE_CB_ID_PLUS_ONE_STRING_PARAM(groupAssetDiscovered);
485ENGAGE_CB_ID_PLUS_ONE_STRING_PARAM(groupAssetRediscovered);
486ENGAGE_CB_ID_PLUS_ONE_STRING_PARAM(groupAssetUndiscovered);
488ENGAGE_CB_NO_PARAMS(licenseChanged)
489ENGAGE_CB_NO_PARAMS(licenseExpired)
490ENGAGE_CB_STR_PARAM(licenseExpiring)
492ENGAGE_CB_ID_PLUS_ONE_STRING_PARAM(groupTimelineEventStarted);
493ENGAGE_CB_ID_PLUS_ONE_STRING_PARAM(groupTimelineEventUpdated);
494ENGAGE_CB_ID_PLUS_ONE_STRING_PARAM(groupTimelineEventEnded);
495ENGAGE_CB_ID_PLUS_ONE_STRING_PARAM(groupTimelineReport);
496ENGAGE_CB_ID_PARAM(groupTimelineReportFailed);
497ENGAGE_CB_ID_PLUS_ONE_STRING_PARAM(groupTimelineGroomed);
499ENGAGE_CB_ID_PLUS_ONE_STRING_PARAM(groupHealthReport);
500ENGAGE_CB_ID_PARAM(groupHealthReportFailed);
502ENGAGE_CB_ID_PLUS_ONE_STRING_PARAM(groupStatsReport);
503ENGAGE_CB_ID_PARAM(groupStatsReportFailed);
505void on_groupRxVolumeChanged(
const char *
id, int16_t leftLevelPerc, int16_t rightLevelPerc,
const char * eventExtraJson)
513 std::vector<CrossThreadCallbackWorker::Parameter*> *params =
new std::vector<CrossThreadCallbackWorker::Parameter*>();
518 cbw->enqueue(params);
520 cbw->RELEASE_OBJECT_REFERENCE();
523ENGAGE_CB_ID_PLUS_ONE_STRING_PARAM(groupRxDtmf)
530 bool haveAFunction =
false;
531 std::string functionName = STRVAL(0);
533 if(info.Length() >= 2 && (!info[1]->IsUndefined()) && (!info[1]->IsNull()))
535 haveAFunction =
true;
541 CallbackMap_t::iterator itr = g_cbMap.find(functionName.c_str());
544 if(itr == g_cbMap.end())
549 g_cbMapLock.unlock();
561 itr->second->RELEASE_OBJECT_REFERENCE();
571 g_cbMapLock.unlock();
576NAN_METHOD(initialize)
584 memset(&g_eventCallbacks, 0,
sizeof(g_eventCallbacks));
586 ENGAGE_CB_TABLE_ENTRY(PFN_ENGAGE_ENGINE_STARTED, engineStarted);
587 ENGAGE_CB_TABLE_ENTRY(PFN_ENGAGE_ENGINE_STOPPED, engineStopped);
588 ENGAGE_CB_TABLE_ENTRY(PFN_ENGAGE_ENGINE_AUDIO_DEVICES_REFRESHED, engineAudioDevicesRefreshed);
590 ENGAGE_CB_TABLE_ENTRY(PFN_ENGAGE_RP_PAUSING_CONNECTION_ATTEMPT, rpPausingConnectionAttempt);
591 ENGAGE_CB_TABLE_ENTRY(PFN_ENGAGE_RP_CONNECTING, rpConnecting);
592 ENGAGE_CB_TABLE_ENTRY(PFN_ENGAGE_RP_CONNECTED, rpConnected);
593 ENGAGE_CB_TABLE_ENTRY(PFN_ENGAGE_RP_DISCONNECTED, rpDisconnected);
594 ENGAGE_CB_TABLE_ENTRY(PFN_ENGAGE_RP_ROUNDTRIP_REPORT, rpRoundtripReport);
596 ENGAGE_CB_TABLE_ENTRY(PFN_ENGAGE_GROUP_CREATED, groupCreated);
597 ENGAGE_CB_TABLE_ENTRY(PFN_ENGAGE_GROUP_CREATE_FAILED, groupCreateFailed);
598 ENGAGE_CB_TABLE_ENTRY(PFN_ENGAGE_GROUP_DELETED, groupDeleted);
600 ENGAGE_CB_TABLE_ENTRY(PFN_ENGAGE_GROUP_CONNECTED, groupConnected);
601 ENGAGE_CB_TABLE_ENTRY(PFN_ENGAGE_GROUP_CONNECT_FAILED, groupConnectFailed);
602 ENGAGE_CB_TABLE_ENTRY(PFN_ENGAGE_GROUP_DISCONNECTED, groupDisconnected);
604 ENGAGE_CB_TABLE_ENTRY(PFN_ENGAGE_GROUP_JOINED, groupJoined);
605 ENGAGE_CB_TABLE_ENTRY(PFN_ENGAGE_GROUP_JOIN_FAILED, groupJoinFailed);
606 ENGAGE_CB_TABLE_ENTRY(PFN_ENGAGE_GROUP_LEFT, groupLeft);
609 ENGAGE_CB_TABLE_ENTRY(PFN_ENGAGE_GROUP_NODE_DISCOVERED, groupNodeDiscovered);
610 ENGAGE_CB_TABLE_ENTRY(PFN_ENGAGE_GROUP_NODE_REDISCOVERED, groupNodeRediscovered);
611 ENGAGE_CB_TABLE_ENTRY(PFN_ENGAGE_GROUP_NODE_UNDISCOVERED, groupNodeUndiscovered);
613 ENGAGE_CB_TABLE_ENTRY(PFN_ENGAGE_GROUP_RX_STARTED, groupRxStarted);
614 ENGAGE_CB_TABLE_ENTRY(PFN_ENGAGE_GROUP_RX_ENDED, groupRxEnded);
615 ENGAGE_CB_TABLE_ENTRY(PFN_ENGAGE_GROUP_RX_SPEAKERS_CHANGED, groupRxSpeakersChanged);
616 ENGAGE_CB_TABLE_ENTRY(PFN_ENGAGE_GROUP_RX_MUTED, groupRxMuted);
617 ENGAGE_CB_TABLE_ENTRY(PFN_ENGAGE_GROUP_RX_UNMUTED, groupRxUnmuted);
619 ENGAGE_CB_TABLE_ENTRY(PFN_ENGAGE_GROUP_TX_STARTED, groupTxStarted);
620 ENGAGE_CB_TABLE_ENTRY(PFN_ENGAGE_GROUP_TX_ENDED, groupTxEnded);
621 ENGAGE_CB_TABLE_ENTRY(PFN_ENGAGE_GROUP_TX_FAILED, groupTxFailed);
622 ENGAGE_CB_TABLE_ENTRY(PFN_ENGAGE_GROUP_TX_USURPED_BY_PRIORITY, groupTxUsurpedByPriority);
623 ENGAGE_CB_TABLE_ENTRY(PFN_ENGAGE_GROUP_MAX_TX_TIME_EXCEEDED, groupMaxTxTimeExceeded);
624 ENGAGE_CB_TABLE_ENTRY(PFN_ENGAGE_GROUP_TX_MUTED, groupTxMuted);
625 ENGAGE_CB_TABLE_ENTRY(PFN_ENGAGE_GROUP_TX_UNMUTED, groupTxUnmuted);
627 ENGAGE_CB_TABLE_ENTRY(PFN_ENGAGE_GROUP_ASSET_DISCOVERED, groupAssetDiscovered);
628 ENGAGE_CB_TABLE_ENTRY(PFN_ENGAGE_GROUP_ASSET_REDISCOVERED, groupAssetRediscovered);
629 ENGAGE_CB_TABLE_ENTRY(PFN_ENGAGE_GROUP_ASSET_UNDISCOVERED, groupAssetUndiscovered);
631 ENGAGE_CB_TABLE_ENTRY(PFN_ENGAGE_LICENSE_CHANGED, licenseChanged);
632 ENGAGE_CB_TABLE_ENTRY(PFN_ENGAGE_LICENSE_EXPIRED, licenseExpired);
633 ENGAGE_CB_TABLE_ENTRY(PFN_ENGAGE_LICENSE_EXPIRING, licenseExpiring);
647 ENGAGE_CB_TABLE_ENTRY(PFN_ENGAGE_GROUP_TIMELINE_EVENT_STARTED, groupTimelineEventStarted);
648 ENGAGE_CB_TABLE_ENTRY(PFN_ENGAGE_GROUP_TIMELINE_EVENT_UPDATED, groupTimelineEventUpdated);
649 ENGAGE_CB_TABLE_ENTRY(PFN_ENGAGE_GROUP_TIMELINE_EVENT_ENDED, groupTimelineEventEnded);
651 ENGAGE_CB_TABLE_ENTRY(PFN_ENGAGE_GROUP_TIMELINE_REPORT, groupTimelineReport);
652 ENGAGE_CB_TABLE_ENTRY(PFN_ENGAGE_GROUP_TIMELINE_REPORT_FAILED, groupTimelineReportFailed);
653 ENGAGE_CB_TABLE_ENTRY(PFN_ENGAGE_GROUP_TIMELINE_GROOMED, groupTimelineGroomed);
655 ENGAGE_CB_TABLE_ENTRY(PFN_ENGAGE_GROUP_HEALTH_REPORT, groupHealthReport);
656 ENGAGE_CB_TABLE_ENTRY(PFN_ENGAGE_GROUP_HEALTH_REPORT_FAILED, groupHealthReportFailed);
658 ENGAGE_CB_TABLE_ENTRY(PFN_ENGAGE_GROUP_STATS_REPORT, groupStatsReport);
659 ENGAGE_CB_TABLE_ENTRY(PFN_ENGAGE_GROUP_STATS_REPORT_FAILED, groupStatsReportFailed);
661 ENGAGE_CB_TABLE_ENTRY(PFN_ENGAGE_GROUP_RX_VOLUME_CHANGED, groupRxVolumeChanged);
662 ENGAGE_CB_TABLE_ENTRY(PFN_ENGAGE_GROUP_RX_DTMF, groupRxDtmf);
670NAN_METHOD(enableCallbacks)
672 g_wantCallbacks =
true;
677NAN_METHOD(disableCallbacks)
679 g_wantCallbacks =
false;
684NAN_METHOD(setLogLevel)
690NAN_METHOD(setLogTagExtension)
732NAN_METHOD(createGroup)
738NAN_METHOD(deleteGroup)
750NAN_METHOD(leaveGroup)
756NAN_METHOD(setGroupRules)
762NAN_METHOD(beginGroupTx)
768NAN_METHOD(beginGroupTxAdvanced)
774NAN_METHOD(endGroupTx)
780NAN_METHOD(setGroupRxTag)
786NAN_METHOD(muteGroupRx)
792NAN_METHOD(unmuteGroupRx)
798NAN_METHOD(muteGroupTx)
804NAN_METHOD(unmuteGroupTx)
810NAN_METHOD(setGroupRxVolume)
816NAN_METHOD(updatePresenceDescriptor)
824 uint8_t* inputBytes = (uint8_t*) node::Buffer::Data(info[0]);
826 size_t inputOfs = INTVAL(1);
827 size_t inputLen = INTVAL(2);
830 uint8_t *outputBytes =
new uint8_t[inputLen + 16 * 2];
832 int bytesInOutput =
engageEncrypt(inputBytes + inputOfs, inputLen, outputBytes, STRVAL(3));
834 if(bytesInOutput > 0)
836 info.GetReturnValue().Set(Nan::CopyBuffer((
char*)outputBytes, bytesInOutput).ToLocalChecked());
839 delete[] outputBytes;
845 uint8_t* inputBytes = (uint8_t*) node::Buffer::Data(info[0]);
847 size_t inputOfs = INTVAL(1);
848 size_t inputLen = INTVAL(2);
851 uint8_t *outputBytes =
new uint8_t[inputLen];
853 int bytesInOutput =
engageDecrypt(inputBytes + inputOfs, inputLen, outputBytes, STRVAL(3));
855 if(bytesInOutput > 0)
857 info.GetReturnValue().Set(Nan::CopyBuffer((
char*)outputBytes, bytesInOutput).ToLocalChecked());
860 delete[] outputBytes;
864NAN_METHOD(getVersion)
877NAN_METHOD(getHardwareReport)
890NAN_METHOD(getActiveLicenseDescriptor)
903NAN_METHOD(getLicenseDescriptor)
916NAN_METHOD(updateLicense)
931NAN_METHOD(queryGroupTimeline)
937NAN_METHOD(queryGroupHealth)
943NAN_METHOD(queryGroupStats)
949NAN_METHOD(getNetworkInterfaceDevices)
962NAN_METHOD(getAudioDevices)
975NAN_METHOD(generateMission)
988NAN_METHOD(generateMissionUsingCertStore)
1001NAN_METHOD(setMissionId)
1007NAN_METHOD(openCertStore)
1013NAN_METHOD(closeCertStore)
1019NAN_METHOD(setCertStoreCertificatePem)
1025NAN_METHOD(setCertStoreCertificateP12)
1031NAN_METHOD(deleteCertStoreCertificate)
1037NAN_METHOD(getCertStoreCertificatePem)
1050NAN_METHOD(getArrayOfCertificateDescriptorsFromPem)
1063NAN_METHOD(getCertificateDescriptorFromPem)
1076NAN_METHOD(importCertStoreElementFromCertStore)
1082NAN_METHOD(queryCertStoreContents)
1095NAN_METHOD(setCertStoreCertificateTags)
1104 NANRETI(
engageLogMsg(INTVAL(0), STRVAL(1), STRVAL(2)));
1108NAN_METHOD(platformNotifyChanges)
1114static void internalEngageLoggingHook(
int level,
const char *tag,
const char *message)
1116 if(g_loggingHookFn.empty())
1127 std::vector<CrossThreadCallbackWorker::Parameter*> *params =
new std::vector<CrossThreadCallbackWorker::Parameter*>();
1131 cbw->enqueue(params);
1133 cbw->RELEASE_OBJECT_REFERENCE();
1137NAN_METHOD(hookEngineLogging)
1139 g_loggingHookFn = STRVAL(0);
1141 if(!g_loggingHookFn.empty())
1152NAN_METHOD(setFipsCrypto)
1158NAN_METHOD(isCryptoFipsValidated)
1164NAN_METHOD(setCertStore)
1166 NANRETI(
engageSetCertStore((uint8_t*) node::Buffer::Data(info[0]), INTVAL(1), STRVAL(2)));
1170NAN_METHOD(getDeviceId)
1184NAN_METHOD(verifyRiff)
1191NAN_METHOD(getRiffDescriptor)
1205NAN_MODULE_INIT(Init)
1209 ENGAGE_BINDING(setLogLevel);
1211 ENGAGE_BINDING(enableCallbacks);
1212 ENGAGE_BINDING(disableCallbacks);
1214 ENGAGE_BINDING(initialize);
1215 ENGAGE_BINDING(shutdown);
1217 ENGAGE_BINDING(start);
1218 ENGAGE_BINDING(stop);
1220 ENGAGE_BINDING(createGroup);
1221 ENGAGE_BINDING(deleteGroup);
1222 ENGAGE_BINDING(joinGroup);
1223 ENGAGE_BINDING(leaveGroup);
1224 ENGAGE_BINDING(setGroupRules);
1226 ENGAGE_BINDING(beginGroupTx);
1227 ENGAGE_BINDING(beginGroupTxAdvanced);
1228 ENGAGE_BINDING(endGroupTx);
1229 ENGAGE_BINDING(setGroupRxTag);
1231 ENGAGE_BINDING(muteGroupRx);
1232 ENGAGE_BINDING(unmuteGroupRx);
1234 ENGAGE_BINDING(muteGroupTx);
1235 ENGAGE_BINDING(unmuteGroupTx);
1237 ENGAGE_BINDING(setGroupRxVolume);
1239 ENGAGE_BINDING(queryGroupTimeline);
1241 ENGAGE_BINDING(updatePresenceDescriptor);
1243 ENGAGE_BINDING(encrypt);
1244 ENGAGE_BINDING(decrypt);
1246 ENGAGE_BINDING(updateLicense);
1247 ENGAGE_BINDING(getVersion);
1248 ENGAGE_BINDING(getHardwareReport);
1249 ENGAGE_BINDING(getNetworkInterfaceDevices);
1250 ENGAGE_BINDING(getAudioDevices);
1252 ENGAGE_BINDING(getActiveLicenseDescriptor);
1253 ENGAGE_BINDING(getLicenseDescriptor);
1255 ENGAGE_BINDING(openCertStore);
1256 ENGAGE_BINDING(closeCertStore);
1257 ENGAGE_BINDING(setCertStore);
1258 ENGAGE_BINDING(setCertStoreCertificatePem);
1259 ENGAGE_BINDING(setCertStoreCertificateP12);
1260 ENGAGE_BINDING(deleteCertStoreCertificate);
1261 ENGAGE_BINDING(getCertStoreCertificatePem);
1262 ENGAGE_BINDING(getCertificateDescriptorFromPem);
1263 ENGAGE_BINDING(importCertStoreElementFromCertStore);
1264 ENGAGE_BINDING(queryCertStoreContents);
1265 ENGAGE_BINDING(setCertStoreCertificateTags);
1267 ENGAGE_BINDING(generateMission);
1268 ENGAGE_BINDING(generateMissionUsingCertStore);
1270 ENGAGE_BINDING(setMissionId);
1271 ENGAGE_BINDING(platformNotifyChanges);
1273 ENGAGE_BINDING(logMsg);
1274 ENGAGE_BINDING(hookEngineLogging);
1276 ENGAGE_BINDING(setFipsCrypto);
1277 ENGAGE_BINDING(isCryptoFipsValidated);
1279 ENGAGE_BINDING(getDeviceId);
1281 ENGAGE_BINDING(verifyRiff);
1282 ENGAGE_BINDING(getRiffDescriptor);
1285NODE_MODULE(engage, Init)
API functions, codes, and more.
ENGAGE_API int engageMuteGroupRx(const char *_Nonnull id)
[ASYNC] Mutes play-out of received audio
ENGAGE_API int engageShutdown()
[SYNC] Shuts down the Engine
ENGAGE_API const char *_Nonnull engageGetLicenseDescriptor(const char *_Nonnull entitlement, const char *_Nonnull key, const char *_Nullable activationCode, const char *_Nullable manufacturerId)
[SYNC] Returns a license descriptor for the parameters passed in
ENGAGE_API int engageQueryGroupStats(const char *_Nonnull id)
[ASYNC] Requests that the Engine deliver a statistics report for the group
ENGAGE_API int engageSetCertStore(const uint8_t *_Nonnull buffer, size_t size, const char *_Nullable passwordHexByteString)
[SYNC] Set the certstore content via buffer
ENGAGE_API int engageDeleteGroup(const char *_Nonnull id)
[ASYNC] Deletes a previously-created group object
ENGAGE_API int engageIsCryptoFipsValidated(void)
[SYNC] Returns 1 if crypto is FIPS140-2 validated, otherwise 0
ENGAGE_API int engageSetFipsCrypto(const char *_Nonnull jsonParams)
[SYNC] Enable FIPS crypto
ENGAGE_API int engageVerifyRiff(const char *_Nonnull fn)
[SYNC] Verifies a recorded RIFF file.
ENGAGE_API int engageRegisterEventCallbacks(const EngageEvents_t *_Nonnull pEvents)
[SYNC] Registers application event handlers with the Engine
ENGAGE_API int engageQueryGroupTimeline(const char *_Nonnull id, const char *_Nonnull jsonParams)
[ASYNC] Requests that the Engine deliver a timeline report for the group
ENGAGE_API int engageSetGroupRxVolume(const char *_Nonnull id, int left, int right)
[ASYNC] Sets the audio play-out volume of the group
ENGAGE_API int engageEndGroupTx(const char *_Nonnull id)
[ASYNC] Ends transmission on an audio group
ENGAGE_API int engagePlatformNotifyChanges(const char *_Nonnull jsonChangesArray)
[SYNC] Notifies Engage of changes reported by the application or platform
ENGAGE_API int engageStop(void)
[ASYNC] Stops the Engine's internal processing
ENGAGE_API const char *_Nonnull engageGetCertStoreCertificatePem(const char *_Nonnull id)
[SYNC] Returns a certificate in PEM format. The private key (if any) is NOT returned.
ENGAGE_API int engageEnableSyslog(int enable)
[SYNC] Enables or disables logging to syslog.
ENGAGE_API int engageCloseCertStore(void)
[SYNC] Closes the current certificate store (if any)
ENGAGE_API const char *_Nonnull engageGetDeviceId()
[SYNC] Returns the device identifier
ENGAGE_API int engageLogMsg(int level, const char *_Nonnull tag, const char *_Nonnull msg)
[SYNC] Log a message via the Engine's logger
ENGAGE_API int engageJoinGroup(const char *_Nonnull id)
[ASYNC] Joins a group
ENGAGE_API int engageSetGroupRules(const char *_Nonnull id, const char *_Nonnull jsonParams)
[ASYNC] Sets the audio play-out volume of the group
ENGAGE_API const char *_Nonnull engageGetHardwareReport()
[SYNC] Returns a hardware report
ENGAGE_API const char *_Nonnull engageGetArrayOfCertificateDescriptorsFromPem(const char *_Nonnull pem)
[SYNC] Returns a JSON array, with each element being an object describing the certificate PEM.
ENGAGE_API int engageQueryGroupHealth(const char *_Nonnull id)
[ASYNC] Requests that the Engine deliver a health report for the group
ENGAGE_API int engageImportCertStoreElementFromCertStore(const char *_Nonnull id, const char *_Nonnull srcId, const char *_Nonnull srcFileName, const char *_Nonnull srcPasswordHexByteString, const char *_Nullable tags)
[SYNC] Adds/updates an element (certificate and optionally private key) from another certificate stor...
ENGAGE_API int engageSetCertStoreCertificateP12(const char *_Nonnull id, uint8_t *_Nonnull data, size_t size, const char *_Nullable password, const char *_Nullable tags)
[SYNC] Adds/updates a certificate and (optionally) private key using P12 content
ENGAGE_API int engageMuteGroupTx(const char *_Nonnull id)
[ASYNC] Mutes microphone audio capture
ENGAGE_API int engageSetGroupRxTag(const char *_Nonnull id, uint16_t tag)
[ASYNC] Sets/clear a audio stream subchannel tag
ENGAGE_API int engageEnableWatchdog(int enable)
[SYNC] Enables or disables the Engine watchdog.
ENGAGE_API int engageOpenCertStore(const char *_Nonnull fileName, const char *_Nullable passwordHexByteString)
[SYNC] Opens a certificate store
ENGAGE_API const char *_Nonnull engageGenerateMission(const char *_Nonnull keyPhrase, int audioGroupCount, const char *_Nullable rallypointHost, const char *_Nullable missionName)
[SYNC] Generates a mission based on a key phrase
ENGAGE_API const char *_Nonnull engageGetRiffDescriptor(const char *_Nonnull fn)
[SYNC] Returns a descriptor for a RIFF file
ENGAGE_API int engageBeginGroupTxAdvanced(const char *_Nonnull id, const char *_Nonnull jsonParams)
[ASYNC] Begin audio transmission on a group with additional parameters
ENGAGE_API int engageDecrypt(const uint8_t *_Nonnull src, size_t size, uint8_t *_Nonnull dst, const char *_Nonnull passwordHexByteString)
[SYNC] Decrypt data using the Engine's cryptography module
ENGAGE_API int engageBeginGroupTx(const char *_Nonnull id, int txPriority, uint32_t txFlags)
[ASYNC] Begin audio transmission on a group
ENGAGE_API int engageInitialize(const char *_Nullable enginePolicyConfiguration, const char *_Nullable userIdentity, const char *_Nullable tempStoragePath)
[SYNC] Initializes the Engine.
ENGAGE_API const char *_Nonnull engageGetNetworkInterfaceDevices()
[SYNC] Returns an array of network interface devices in JSON format
ENGAGE_API int engageSetLoggingOutputOverride(const _Nullable PFN_ENGAGE_LOG_HOOK pfnHook)
[SYNC] Sets/clears the output override callback for log messages.
ENGAGE_API const char *_Nonnull engageGetActiveLicenseDescriptor()
[SYNC] Returns the currently-active license descriptor
ENGAGE_API int engageCreateGroup(const char *_Nonnull jsonConfiguration)
[ASYNC] Creates a group object
ENGAGE_API int engageUpdatePresenceDescriptor(const char *_Nonnull id, const char *_Nonnull descriptorJson, int forceBeacon)
[ASYNC] Updates the application-defined elements of a presence descriptor
ENGAGE_API int engageEncrypt(const uint8_t *_Nonnull src, size_t size, uint8_t *_Nonnull dst, const char *_Nonnull passwordHexByteString)
[SYNC] Encrypt data using the Engine's cryptography module
ENGAGE_API int engageUnmuteGroupTx(const char *_Nonnull id)
[ASYNC] Unmutes microphone audio capture
ENGAGE_API const char *_Nonnull engageGetVersion()
[SYNC] Returns the version of the Engine
ENGAGE_API const char *_Nonnull engageGetCertificateDescriptorFromPem(const char *_Nonnull pem)
[SYNC] Returns a JSON object describing the certificate PEM.
ENGAGE_API int engageSetCertStoreCertificateTags(const char *_Nonnull id, const char *_Nullable tags)
[SYNC] Updates a certificate's tags
ENGAGE_API int engageLeaveGroup(const char *_Nonnull id)
[ASYNC] Leaves a group
ENGAGE_API int engageSetLogLevel(int level)
[SYNC] Sets the Engine's logging level.
ENGAGE_API int engageSetCertStoreCertificatePem(const char *_Nonnull id, const char *_Nonnull certificatePem, const char *_Nullable privateKeyPem, const char *_Nullable tags)
[SYNC] Adds/updates a certificate and (optionally) private key using PEM strings
ENGAGE_API int engageSetLogTagExtension(const char *_Nullable tagExtension)
[SYNC] Sets the Engine's log tag extension.
ENGAGE_API const char *_Nonnull engageGenerateMissionUsingCertStore(const char *_Nonnull keyPhrase, int audioGroupCount, const char *_Nullable rallypointHost, const char *_Nullable missionName, const char *_Nonnull certStoreFn, const char *_Nullable certStorePasswordHexByteString, const char *_Nullable certStoreElement)
[SYNC] Generates a mission based on a key phrase and using a specified certificate store
ENGAGE_API int engageUpdateLicense(const char *_Nonnull entitlement, const char *_Nonnull key, const char *_Nullable activationCode, const char *_Nullable manufacturerId)
[ASYNC] Update the active license with new parameters
ENGAGE_API const char *_Nonnull engageQueryCertStoreContents(const char *_Nonnull fileName, const char *_Nullable passwordHexByteString)
[SYNC] Returns an extended descriptor of named certificate store
ENGAGE_API const char *_Nonnull engageGetAudioDevices()
[SYNC] Returns an array of audio device descriptor interface devices in JSON format
ENGAGE_API int engageSetMissionId(const char *_Nullable missionId)
[SYNC] Sets the (optional) mission ID for the Engine
ENGAGE_API int engageStart(void)
[ASYNC] Starts the Engine
ENGAGE_API int engageDeleteCertStoreCertificate(const char *_Nonnull id)
[SYNC] Deletes a certificate and its private key (if any)
ENGAGE_API int engageUnmuteGroupRx(const char *_Nonnull id)
[ASYNC] Unmutes play-out of received audio
static const int ENGAGE_RESULT_OK
The request was succesful.
static const int ENGAGE_SYSLOG_ENABLE
Enables syslog output on supported systems.
static const int ENGAGE_SYSLOG_DISABLE
Disables syslog output.
static const int ENGAGE_WATCHDOG_DISABLE
Disables the watchdog - has no effect if the watchdog is disabled in the policy configuration.
static const int ENGAGE_WATCHDOG_ENABLE
Enables the watchdog - has no effect if the watchdog is disabled in the policy configuration.