engage-engine 1.256.90960034 → 1.257.90970036

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/engage.cpp CHANGED
@@ -11,6 +11,7 @@
11
11
  #include <map>
12
12
  #include <mutex>
13
13
  #include <atomic>
14
+ #include <cstring>
14
15
 
15
16
  #include "EngageInterface.h"
16
17
  #include "EngagePlatformNotifications.h"
@@ -107,7 +108,7 @@ public:
107
108
  class Parameter
108
109
  {
109
110
  public:
110
- typedef enum {ptString, ptInt, ptStringVector} Type_t;
111
+ typedef enum {ptString, ptInt, ptStringVector, ptBuffer} Type_t;
111
112
 
112
113
  Type_t _type;
113
114
  };
@@ -161,6 +162,37 @@ public:
161
162
  std::vector<std::string> _val;
162
163
  };
163
164
 
165
+ class BufferParameter : public Parameter
166
+ {
167
+ public:
168
+ BufferParameter(const uint8_t *data, size_t size)
169
+ {
170
+ _type = ptBuffer;
171
+ if(data != nullptr && size > 0)
172
+ {
173
+ _val = new uint8_t[size];
174
+ _size = size;
175
+ memcpy(_val, data, size);
176
+ }
177
+ else
178
+ {
179
+ _val = nullptr;
180
+ _size = 0;
181
+ }
182
+ }
183
+
184
+ ~BufferParameter()
185
+ {
186
+ if(_val != nullptr)
187
+ {
188
+ delete[] _val;
189
+ }
190
+ }
191
+
192
+ uint8_t *_val;
193
+ size_t _size;
194
+ };
195
+
164
196
  explicit CrossThreadCallbackWorker(v8::Local<v8::Function> fn)
165
197
  {
166
198
  Nan::HandleScope scope;
@@ -339,6 +371,19 @@ private:
339
371
  {
340
372
  argv[index] = Nan::New<v8::Integer>(((IntParameter*)(*itr))->_val);
341
373
  }
374
+ else if((*itr)->_type == Parameter::ptBuffer)
375
+ {
376
+ BufferParameter *bp = (BufferParameter*)(*itr);
377
+ if(bp->_val != nullptr && bp->_size > 0)
378
+ {
379
+ argv[index] = Nan::CopyBuffer((char*)bp->_val, bp->_size).ToLocalChecked();
380
+ }
381
+ else
382
+ {
383
+ // Create empty buffer for zero-size case
384
+ argv[index] = Nan::CopyBuffer("", 0).ToLocalChecked();
385
+ }
386
+ }
342
387
 
343
388
  index++;
344
389
  }
@@ -526,6 +571,46 @@ void on_groupRxVolumeChanged(const char *id, int16_t leftLevelPerc, int16_t righ
526
571
 
527
572
  ENGAGE_CB_ID_PLUS_ONE_STRING_PARAM(groupRxDtmf)
528
573
 
574
+ ENGAGE_CB_ID_PARAM(groupBlobSent)
575
+ ENGAGE_CB_ID_PARAM(groupBlobSendFailed)
576
+
577
+ ENGAGE_CB_ID_PARAM(groupRawSent)
578
+ ENGAGE_CB_ID_PARAM(groupRawSendFailed)
579
+
580
+ void on_groupBlobReceived(const char *id, const char *blobInfoJson, const uint8_t *blob, size_t blobSize, const char *eventExtraJson)
581
+ {
582
+ CrossThreadCallbackWorker *cbw = getCallback("groupBlobReceived");
583
+ if(!cbw)
584
+ {
585
+ return;
586
+ }
587
+
588
+ std::vector<CrossThreadCallbackWorker::Parameter*> *params = new std::vector<CrossThreadCallbackWorker::Parameter*>();
589
+ params->push_back(new CrossThreadCallbackWorker::StringParameter(id));
590
+ params->push_back(new CrossThreadCallbackWorker::StringParameter(blobInfoJson));
591
+ params->push_back(new CrossThreadCallbackWorker::BufferParameter(blob, blobSize));
592
+ params->push_back(new CrossThreadCallbackWorker::StringParameter(eventExtraJson));
593
+ cbw->enqueue(params);
594
+
595
+ cbw->RELEASE_OBJECT_REFERENCE();
596
+ }
597
+
598
+ void on_groupRawReceived(const char *id, const uint8_t *raw, size_t rawSize, const char *eventExtraJson)
599
+ {
600
+ CrossThreadCallbackWorker *cbw = getCallback("groupRawReceived");
601
+ if(!cbw)
602
+ {
603
+ return;
604
+ }
605
+
606
+ std::vector<CrossThreadCallbackWorker::Parameter*> *params = new std::vector<CrossThreadCallbackWorker::Parameter*>();
607
+ params->push_back(new CrossThreadCallbackWorker::StringParameter(id));
608
+ params->push_back(new CrossThreadCallbackWorker::BufferParameter(raw, rawSize));
609
+ params->push_back(new CrossThreadCallbackWorker::StringParameter(eventExtraJson));
610
+ cbw->enqueue(params);
611
+
612
+ cbw->RELEASE_OBJECT_REFERENCE();
613
+ }
529
614
 
530
615
  //--------------------------------------------------------
531
616
  // Registers an event name and the JS callback function
@@ -636,17 +721,17 @@ NAN_METHOD(initialize)
636
721
  ENGAGE_CB_TABLE_ENTRY(PFN_ENGAGE_LICENSE_EXPIRED, licenseExpired);
637
722
  ENGAGE_CB_TABLE_ENTRY(PFN_ENGAGE_LICENSE_EXPIRING, licenseExpiring);
638
723
 
639
- // TODO PFN_ENGAGE_GROUP_BLOB_SENT
640
- // TODO PFN_ENGAGE_GROUP_BLOB_SEND_FAILED
641
- // TODO PFN_ENGAGE_GROUP_BLOB_RECEIVED
642
-
643
724
  // TODO PFN_ENGAGE_GROUP_RTP_SENT
644
725
  // TODO PFN_ENGAGE_GROUP_RTP_SEND_FAILED
645
726
  // TODO PFN_ENGAGE_GROUP_RTP_RECEIVED
646
727
 
647
- // TODO PFN_ENGAGE_GROUP_RAW_SENT
648
- // TODO PFN_ENGAGE_GROUP_RAW_SEND_FAILED
649
- // TODO PFN_ENGAGE_GROUP_RAW_RECEIVED
728
+ ENGAGE_CB_TABLE_ENTRY(PFN_ENGAGE_GROUP_BLOB_SENT, groupBlobSent);
729
+ ENGAGE_CB_TABLE_ENTRY(PFN_ENGAGE_GROUP_BLOB_SEND_FAILED, groupBlobSendFailed);
730
+ ENGAGE_CB_TABLE_ENTRY(PFN_ENGAGE_GROUP_BLOB_RECEIVED, groupBlobReceived);
731
+
732
+ ENGAGE_CB_TABLE_ENTRY(PFN_ENGAGE_GROUP_RAW_SENT, groupRawSent);
733
+ ENGAGE_CB_TABLE_ENTRY(PFN_ENGAGE_GROUP_RAW_SEND_FAILED, groupRawSendFailed);
734
+ ENGAGE_CB_TABLE_ENTRY(PFN_ENGAGE_GROUP_RAW_RECEIVED, groupRawReceived);
650
735
 
651
736
  ENGAGE_CB_TABLE_ENTRY(PFN_ENGAGE_GROUP_TIMELINE_EVENT_STARTED, groupTimelineEventStarted);
652
737
  ENGAGE_CB_TABLE_ENTRY(PFN_ENGAGE_GROUP_TIMELINE_EVENT_UPDATED, groupTimelineEventUpdated);
@@ -701,13 +786,13 @@ NAN_METHOD(setLogTagExtension)
701
786
  }
702
787
 
703
788
  //--------------------------------------------------------
704
- NAN_METHOD(engageEnableSyslog)
789
+ NAN_METHOD(enableSyslog)
705
790
  {
706
791
  NANRETI(engageEnableSyslog(INTVAL(0) == 1 ? ENGAGE_SYSLOG_ENABLE : ENGAGE_SYSLOG_DISABLE));
707
792
  }
708
793
 
709
794
  //--------------------------------------------------------
710
- NAN_METHOD(engageEnableWatchdog)
795
+ NAN_METHOD(enableWatchdog)
711
796
  {
712
797
  NANRETI(engageEnableWatchdog(INTVAL(0) == 1 ? ENGAGE_WATCHDOG_ENABLE : ENGAGE_WATCHDOG_DISABLE));
713
798
  }
@@ -929,8 +1014,49 @@ NAN_METHOD(updateLicense)
929
1014
  // TODO: engageSendGroupRtp
930
1015
  // TODO: engageRegisterGroupRtpHandler
931
1016
  // TODO: engageUnregisterGroupRtpHandler
932
- // TODO: engageSendGroupBlob
933
- // TODO: engageSendGroupRaw
1017
+
1018
+ //--------------------------------------------------------
1019
+ NAN_METHOD(sendGroupBlob)
1020
+ {
1021
+ // Get the buffer data
1022
+ uint8_t* blobBytes = (uint8_t*) node::Buffer::Data(info[1]);
1023
+
1024
+ // Get size - can use buffer length or provided size parameter
1025
+ size_t blobSize;
1026
+ if(info.Length() >= 3 && info[2]->IsNumber())
1027
+ {
1028
+ blobSize = INTVAL(2);
1029
+ }
1030
+ else
1031
+ {
1032
+ // Fallback to buffer length if size not provided
1033
+ blobSize = node::Buffer::Length(info[1]);
1034
+ }
1035
+
1036
+ NANRETI(engageSendGroupBlob(STRVAL(0), blobBytes, blobSize, STRVAL(3)));
1037
+ }
1038
+
1039
+ //--------------------------------------------------------
1040
+ NAN_METHOD(sendGroupRaw)
1041
+ {
1042
+ // Get the buffer data
1043
+ uint8_t* rawBytes = (uint8_t*) node::Buffer::Data(info[1]);
1044
+
1045
+ // Get size - can use buffer length or provided size parameter
1046
+ size_t rawSize;
1047
+ if(info.Length() >= 3 && info[2]->IsNumber())
1048
+ {
1049
+ rawSize = INTVAL(2);
1050
+ }
1051
+ else
1052
+ {
1053
+ // Fallback to buffer length if size not provided
1054
+ rawSize = node::Buffer::Length(info[1]);
1055
+ }
1056
+
1057
+ NANRETI(engageSendGroupRaw(STRVAL(0), rawBytes, rawSize, STRVAL(3)));
1058
+ }
1059
+
934
1060
  // TODO: engagePlatformServiceDiscovered
935
1061
  // TODO: engagePlatformServiceRediscovered
936
1062
  // TODO: engagePlatformServiceUndiscovered
@@ -1275,6 +1401,8 @@ NAN_MODULE_INIT(Init)
1275
1401
 
1276
1402
  ENGAGE_BINDING(encrypt);
1277
1403
  ENGAGE_BINDING(decrypt);
1404
+ ENGAGE_BINDING(sendGroupBlob);
1405
+ ENGAGE_BINDING(sendGroupRaw);
1278
1406
 
1279
1407
  ENGAGE_BINDING(updateLicense);
1280
1408
  ENGAGE_BINDING(getVersion);
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "engage-engine",
3
- "version": "1.256.90960034",
3
+ "version": "1.257.90970036",
4
4
  "description": "Use Engage to communicate with everyone, everywhere, from any device",
5
5
  "scripts": {
6
6
  "test": "echo \"Error: no test specified\" && exit 1"
@@ -22,6 +22,7 @@
22
22
  "homepage": "https://github.com/rallytac/pub#readme",
23
23
  "dependencies": {
24
24
  "bindings": "^1.5.0",
25
+ "chalk": "^4.1.2",
25
26
  "nan": "^2.14.0",
26
27
  "node-gyp": "^9.0.3"
27
28
  }