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);
505ENGAGE_CB_ID_PARAM(bridgeCreated)
506ENGAGE_CB_ID_PARAM(bridgeCreateFailed)
507ENGAGE_CB_ID_PARAM(bridgeDeleted)
509void on_groupRxVolumeChanged(
const char *
id, int16_t leftLevelPerc, int16_t rightLevelPerc,
const char * eventExtraJson)
517 std::vector<CrossThreadCallbackWorker::Parameter*> *params =
new std::vector<CrossThreadCallbackWorker::Parameter*>();
522 cbw->enqueue(params);
524 cbw->RELEASE_OBJECT_REFERENCE();
527ENGAGE_CB_ID_PLUS_ONE_STRING_PARAM(groupRxDtmf)
534 bool haveAFunction =
false;
535 std::string functionName = STRVAL(0);
537 if(info.Length() >= 2 && (!info[1]->IsUndefined()) && (!info[1]->IsNull()))
539 haveAFunction =
true;
545 CallbackMap_t::iterator itr = g_cbMap.find(functionName.c_str());
548 if(itr == g_cbMap.end())
553 g_cbMapLock.unlock();
565 itr->second->RELEASE_OBJECT_REFERENCE();
575 g_cbMapLock.unlock();
580NAN_METHOD(initialize)
588 memset(&g_eventCallbacks, 0,
sizeof(g_eventCallbacks));
590 ENGAGE_CB_TABLE_ENTRY(PFN_ENGAGE_ENGINE_STARTED, engineStarted);
591 ENGAGE_CB_TABLE_ENTRY(PFN_ENGAGE_ENGINE_STOPPED, engineStopped);
592 ENGAGE_CB_TABLE_ENTRY(PFN_ENGAGE_ENGINE_AUDIO_DEVICES_REFRESHED, engineAudioDevicesRefreshed);
594 ENGAGE_CB_TABLE_ENTRY(PFN_ENGAGE_RP_PAUSING_CONNECTION_ATTEMPT, rpPausingConnectionAttempt);
595 ENGAGE_CB_TABLE_ENTRY(PFN_ENGAGE_RP_CONNECTING, rpConnecting);
596 ENGAGE_CB_TABLE_ENTRY(PFN_ENGAGE_RP_CONNECTED, rpConnected);
597 ENGAGE_CB_TABLE_ENTRY(PFN_ENGAGE_RP_DISCONNECTED, rpDisconnected);
598 ENGAGE_CB_TABLE_ENTRY(PFN_ENGAGE_RP_ROUNDTRIP_REPORT, rpRoundtripReport);
600 ENGAGE_CB_TABLE_ENTRY(PFN_ENGAGE_GROUP_CREATED, groupCreated);
601 ENGAGE_CB_TABLE_ENTRY(PFN_ENGAGE_GROUP_CREATE_FAILED, groupCreateFailed);
602 ENGAGE_CB_TABLE_ENTRY(PFN_ENGAGE_GROUP_DELETED, groupDeleted);
604 ENGAGE_CB_TABLE_ENTRY(PFN_ENGAGE_GROUP_CONNECTED, groupConnected);
605 ENGAGE_CB_TABLE_ENTRY(PFN_ENGAGE_GROUP_CONNECT_FAILED, groupConnectFailed);
606 ENGAGE_CB_TABLE_ENTRY(PFN_ENGAGE_GROUP_DISCONNECTED, groupDisconnected);
608 ENGAGE_CB_TABLE_ENTRY(PFN_ENGAGE_GROUP_JOINED, groupJoined);
609 ENGAGE_CB_TABLE_ENTRY(PFN_ENGAGE_GROUP_JOIN_FAILED, groupJoinFailed);
610 ENGAGE_CB_TABLE_ENTRY(PFN_ENGAGE_GROUP_LEFT, groupLeft);
613 ENGAGE_CB_TABLE_ENTRY(PFN_ENGAGE_GROUP_NODE_DISCOVERED, groupNodeDiscovered);
614 ENGAGE_CB_TABLE_ENTRY(PFN_ENGAGE_GROUP_NODE_REDISCOVERED, groupNodeRediscovered);
615 ENGAGE_CB_TABLE_ENTRY(PFN_ENGAGE_GROUP_NODE_UNDISCOVERED, groupNodeUndiscovered);
617 ENGAGE_CB_TABLE_ENTRY(PFN_ENGAGE_GROUP_RX_STARTED, groupRxStarted);
618 ENGAGE_CB_TABLE_ENTRY(PFN_ENGAGE_GROUP_RX_ENDED, groupRxEnded);
619 ENGAGE_CB_TABLE_ENTRY(PFN_ENGAGE_GROUP_RX_SPEAKERS_CHANGED, groupRxSpeakersChanged);
620 ENGAGE_CB_TABLE_ENTRY(PFN_ENGAGE_GROUP_RX_MUTED, groupRxMuted);
621 ENGAGE_CB_TABLE_ENTRY(PFN_ENGAGE_GROUP_RX_UNMUTED, groupRxUnmuted);
623 ENGAGE_CB_TABLE_ENTRY(PFN_ENGAGE_GROUP_TX_STARTED, groupTxStarted);
624 ENGAGE_CB_TABLE_ENTRY(PFN_ENGAGE_GROUP_TX_ENDED, groupTxEnded);
625 ENGAGE_CB_TABLE_ENTRY(PFN_ENGAGE_GROUP_TX_FAILED, groupTxFailed);
626 ENGAGE_CB_TABLE_ENTRY(PFN_ENGAGE_GROUP_TX_USURPED_BY_PRIORITY, groupTxUsurpedByPriority);
627 ENGAGE_CB_TABLE_ENTRY(PFN_ENGAGE_GROUP_MAX_TX_TIME_EXCEEDED, groupMaxTxTimeExceeded);
628 ENGAGE_CB_TABLE_ENTRY(PFN_ENGAGE_GROUP_TX_MUTED, groupTxMuted);
629 ENGAGE_CB_TABLE_ENTRY(PFN_ENGAGE_GROUP_TX_UNMUTED, groupTxUnmuted);
631 ENGAGE_CB_TABLE_ENTRY(PFN_ENGAGE_GROUP_ASSET_DISCOVERED, groupAssetDiscovered);
632 ENGAGE_CB_TABLE_ENTRY(PFN_ENGAGE_GROUP_ASSET_REDISCOVERED, groupAssetRediscovered);
633 ENGAGE_CB_TABLE_ENTRY(PFN_ENGAGE_GROUP_ASSET_UNDISCOVERED, groupAssetUndiscovered);
635 ENGAGE_CB_TABLE_ENTRY(PFN_ENGAGE_LICENSE_CHANGED, licenseChanged);
636 ENGAGE_CB_TABLE_ENTRY(PFN_ENGAGE_LICENSE_EXPIRED, licenseExpired);
637 ENGAGE_CB_TABLE_ENTRY(PFN_ENGAGE_LICENSE_EXPIRING, licenseExpiring);
651 ENGAGE_CB_TABLE_ENTRY(PFN_ENGAGE_GROUP_TIMELINE_EVENT_STARTED, groupTimelineEventStarted);
652 ENGAGE_CB_TABLE_ENTRY(PFN_ENGAGE_GROUP_TIMELINE_EVENT_UPDATED, groupTimelineEventUpdated);
653 ENGAGE_CB_TABLE_ENTRY(PFN_ENGAGE_GROUP_TIMELINE_EVENT_ENDED, groupTimelineEventEnded);
655 ENGAGE_CB_TABLE_ENTRY(PFN_ENGAGE_GROUP_TIMELINE_REPORT, groupTimelineReport);
656 ENGAGE_CB_TABLE_ENTRY(PFN_ENGAGE_GROUP_TIMELINE_REPORT_FAILED, groupTimelineReportFailed);
657 ENGAGE_CB_TABLE_ENTRY(PFN_ENGAGE_GROUP_TIMELINE_GROOMED, groupTimelineGroomed);
659 ENGAGE_CB_TABLE_ENTRY(PFN_ENGAGE_GROUP_HEALTH_REPORT, groupHealthReport);
660 ENGAGE_CB_TABLE_ENTRY(PFN_ENGAGE_GROUP_HEALTH_REPORT_FAILED, groupHealthReportFailed);
662 ENGAGE_CB_TABLE_ENTRY(PFN_ENGAGE_GROUP_STATS_REPORT, groupStatsReport);
663 ENGAGE_CB_TABLE_ENTRY(PFN_ENGAGE_GROUP_STATS_REPORT_FAILED, groupStatsReportFailed);
665 ENGAGE_CB_TABLE_ENTRY(PFN_ENGAGE_GROUP_RX_VOLUME_CHANGED, groupRxVolumeChanged);
666 ENGAGE_CB_TABLE_ENTRY(PFN_ENGAGE_GROUP_RX_DTMF, groupRxDtmf);
668 ENGAGE_CB_TABLE_ENTRY(PFN_ENGAGE_BRIDGE_CREATED, bridgeCreated);
669 ENGAGE_CB_TABLE_ENTRY(PFN_ENGAGE_BRIDGE_CREATE_FAILED, bridgeCreateFailed);
670 ENGAGE_CB_TABLE_ENTRY(PFN_ENGAGE_BRIDGE_DELETED, bridgeDeleted);
678NAN_METHOD(enableCallbacks)
680 g_wantCallbacks =
true;
685NAN_METHOD(disableCallbacks)
687 g_wantCallbacks =
false;
692NAN_METHOD(setLogLevel)
698NAN_METHOD(setLogTagExtension)
740NAN_METHOD(createGroup)
746NAN_METHOD(deleteGroup)
758NAN_METHOD(leaveGroup)
764NAN_METHOD(setGroupRules)
770NAN_METHOD(beginGroupTx)
776NAN_METHOD(beginGroupTxAdvanced)
782NAN_METHOD(endGroupTx)
788NAN_METHOD(setGroupRxTag)
794NAN_METHOD(muteGroupRx)
800NAN_METHOD(unmuteGroupRx)
806NAN_METHOD(muteGroupTx)
812NAN_METHOD(unmuteGroupTx)
818NAN_METHOD(setGroupRxVolume)
824NAN_METHOD(updatePresenceDescriptor)
832 uint8_t* inputBytes = (uint8_t*) node::Buffer::Data(info[0]);
834 size_t inputOfs = INTVAL(1);
835 size_t inputLen = INTVAL(2);
838 uint8_t *outputBytes =
new uint8_t[inputLen + 16 * 2];
840 int bytesInOutput =
engageEncrypt(inputBytes + inputOfs, inputLen, outputBytes, STRVAL(3));
842 if(bytesInOutput > 0)
844 info.GetReturnValue().Set(Nan::CopyBuffer((
char*)outputBytes, bytesInOutput).ToLocalChecked());
847 delete[] outputBytes;
853 uint8_t* inputBytes = (uint8_t*) node::Buffer::Data(info[0]);
855 size_t inputOfs = INTVAL(1);
856 size_t inputLen = INTVAL(2);
859 uint8_t *outputBytes =
new uint8_t[inputLen];
861 int bytesInOutput =
engageDecrypt(inputBytes + inputOfs, inputLen, outputBytes, STRVAL(3));
863 if(bytesInOutput > 0)
865 info.GetReturnValue().Set(Nan::CopyBuffer((
char*)outputBytes, bytesInOutput).ToLocalChecked());
868 delete[] outputBytes;
872NAN_METHOD(getVersion)
885NAN_METHOD(getHardwareReport)
898NAN_METHOD(getActiveLicenseDescriptor)
911NAN_METHOD(getLicenseDescriptor)
924NAN_METHOD(updateLicense)
939NAN_METHOD(queryGroupTimeline)
945NAN_METHOD(queryGroupHealth)
951NAN_METHOD(queryGroupStats)
957NAN_METHOD(getNetworkInterfaceDevices)
970NAN_METHOD(getAudioDevices)
983NAN_METHOD(generateMission)
996NAN_METHOD(generateMissionUsingCertStore)
1009NAN_METHOD(setMissionId)
1015NAN_METHOD(openCertStore)
1021NAN_METHOD(closeCertStore)
1027NAN_METHOD(setCertStoreCertificatePem)
1033NAN_METHOD(setCertStoreCertificateP12)
1039NAN_METHOD(deleteCertStoreCertificate)
1045NAN_METHOD(getCertStoreCertificatePem)
1058NAN_METHOD(getArrayOfCertificateDescriptorsFromPem)
1071NAN_METHOD(getCertificateDescriptorFromPem)
1084NAN_METHOD(importCertStoreElementFromCertStore)
1090NAN_METHOD(queryCertStoreContents)
1103NAN_METHOD(setCertStoreCertificateTags)
1112 NANRETI(
engageLogMsg(INTVAL(0), STRVAL(1), STRVAL(2)));
1116NAN_METHOD(platformNotifyChanges)
1122static void internalEngageLoggingHook(
int level,
const char *tag,
const char *message)
1124 if(g_loggingHookFn.empty())
1135 std::vector<CrossThreadCallbackWorker::Parameter*> *params =
new std::vector<CrossThreadCallbackWorker::Parameter*>();
1139 cbw->enqueue(params);
1141 cbw->RELEASE_OBJECT_REFERENCE();
1145NAN_METHOD(hookEngineLogging)
1147 g_loggingHookFn = STRVAL(0);
1149 if(!g_loggingHookFn.empty())
1160NAN_METHOD(setFipsCrypto)
1166NAN_METHOD(isCryptoFipsValidated)
1172NAN_METHOD(setCertStore)
1174 NANRETI(
engageSetCertStore((uint8_t*) node::Buffer::Data(info[0]), INTVAL(1), STRVAL(2)));
1178NAN_METHOD(getDeviceId)
1192NAN_METHOD(verifyRiff)
1199NAN_METHOD(getRiffDescriptor)
1213NAN_METHOD(beginGroupPcmPowerTracking)
1220NAN_METHOD(endGroupPcmPowerTracking)
1226NAN_METHOD(createBridge)
1232NAN_METHOD(deleteBridge)
1238NAN_MODULE_INIT(Init)
1242 ENGAGE_BINDING(setLogLevel);
1244 ENGAGE_BINDING(enableCallbacks);
1245 ENGAGE_BINDING(disableCallbacks);
1247 ENGAGE_BINDING(initialize);
1248 ENGAGE_BINDING(shutdown);
1250 ENGAGE_BINDING(start);
1251 ENGAGE_BINDING(stop);
1253 ENGAGE_BINDING(createGroup);
1254 ENGAGE_BINDING(deleteGroup);
1255 ENGAGE_BINDING(joinGroup);
1256 ENGAGE_BINDING(leaveGroup);
1257 ENGAGE_BINDING(setGroupRules);
1259 ENGAGE_BINDING(beginGroupTx);
1260 ENGAGE_BINDING(beginGroupTxAdvanced);
1261 ENGAGE_BINDING(endGroupTx);
1262 ENGAGE_BINDING(setGroupRxTag);
1264 ENGAGE_BINDING(muteGroupRx);
1265 ENGAGE_BINDING(unmuteGroupRx);
1267 ENGAGE_BINDING(muteGroupTx);
1268 ENGAGE_BINDING(unmuteGroupTx);
1270 ENGAGE_BINDING(setGroupRxVolume);
1272 ENGAGE_BINDING(queryGroupTimeline);
1274 ENGAGE_BINDING(updatePresenceDescriptor);
1276 ENGAGE_BINDING(encrypt);
1277 ENGAGE_BINDING(decrypt);
1279 ENGAGE_BINDING(updateLicense);
1280 ENGAGE_BINDING(getVersion);
1281 ENGAGE_BINDING(getHardwareReport);
1282 ENGAGE_BINDING(getNetworkInterfaceDevices);
1283 ENGAGE_BINDING(getAudioDevices);
1285 ENGAGE_BINDING(getActiveLicenseDescriptor);
1286 ENGAGE_BINDING(getLicenseDescriptor);
1288 ENGAGE_BINDING(openCertStore);
1289 ENGAGE_BINDING(closeCertStore);
1290 ENGAGE_BINDING(setCertStore);
1291 ENGAGE_BINDING(setCertStoreCertificatePem);
1292 ENGAGE_BINDING(setCertStoreCertificateP12);
1293 ENGAGE_BINDING(deleteCertStoreCertificate);
1294 ENGAGE_BINDING(getCertStoreCertificatePem);
1295 ENGAGE_BINDING(getCertificateDescriptorFromPem);
1296 ENGAGE_BINDING(importCertStoreElementFromCertStore);
1297 ENGAGE_BINDING(queryCertStoreContents);
1298 ENGAGE_BINDING(setCertStoreCertificateTags);
1300 ENGAGE_BINDING(generateMission);
1301 ENGAGE_BINDING(generateMissionUsingCertStore);
1303 ENGAGE_BINDING(setMissionId);
1304 ENGAGE_BINDING(platformNotifyChanges);
1306 ENGAGE_BINDING(logMsg);
1307 ENGAGE_BINDING(hookEngineLogging);
1309 ENGAGE_BINDING(setFipsCrypto);
1310 ENGAGE_BINDING(isCryptoFipsValidated);
1312 ENGAGE_BINDING(getDeviceId);
1314 ENGAGE_BINDING(verifyRiff);
1315 ENGAGE_BINDING(getRiffDescriptor);
1317 ENGAGE_BINDING(beginGroupPcmPowerTracking);
1318 ENGAGE_BINDING(endGroupPcmPowerTracking);
1320 ENGAGE_BINDING(createBridge);
1321 ENGAGE_BINDING(deleteBridge);
1324NODE_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 engageCreateBridge(const char *_Nonnull jsonConfiguration)
[ASYNC] Creates a bridge object
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 engageEndGroupPcmPowerTracking(const char *_Nonnull id)
[ASYNC] End tracking of input and output PCM power for the group
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 int engageBeginGroupPcmPowerTracking(const char *_Nonnull id)
[ASYNC] Begins tracking of input and output PCM power for the group
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 int engageDeleteBridge(const char *_Nonnull id)
[ASYNC] Deletes a bridge object
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.