rticonnextdds-connector 1.1.0 → 1.2.0-rc5

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rticonnextdds-connector",
3
- "version": "1.1.0",
3
+ "version": "1.2.0-rc5",
4
4
  "description": "RTI Connector for JavaScript",
5
5
  "main": "rticonnextdds-connector.js",
6
6
  "files": [
@@ -19,6 +19,14 @@
19
19
  "ffi-napi": "^3.1.0",
20
20
  "sleep": "^6.3.0"
21
21
  },
22
+ "scripts": {
23
+ "test": "mocha ./test/nodejs/",
24
+ "test-ci": "mocha ./test/nodejs/ --reporter mocha-junit-reporter",
25
+ "coverage": "nyc --reporter=clover --reporter=lcov --reporter=text-summary --check-coverage npm run test",
26
+ "coverage-ci": "nyc --reporter=clover --reporter=lcov --reporter=text-summary --check-coverage npm run test-ci",
27
+ "lint": "eslint rticonnextdds-connector.js test/nodejs/ --ext .js",
28
+ "lint-fix": "eslint --fix rticonnextdds-connector.js test/nodejs/ --ext .js"
29
+ },
22
30
  "keywords": [
23
31
  "rti",
24
32
  "dds",
@@ -33,5 +41,17 @@
33
41
  "bugs": {
34
42
  "url": "https://github.com/rticommunity/rticonnextdds-connector-js/issues"
35
43
  },
36
- "homepage": "https://github.com/rticommunity/rticonnextdds-connector-js"
44
+ "homepage": "https://github.com/rticommunity/rticonnextdds-connector-js",
45
+ "devDependencies": {
46
+ "babel-eslint": "^10.1.0",
47
+ "chai": "^4.3.4",
48
+ "chai-as-promised": "^7.1.1",
49
+ "eslint": "^7.29.0",
50
+ "eslint-config-standard": "^16.0.3",
51
+ "eslint-plugin-import": "^2.23.4",
52
+ "eslint-plugin-node": "^11.1.0",
53
+ "eslint-plugin-promise": "^5.1.0",
54
+ "nyc": "^15.1.0",
55
+ "sinon": "^10.0.0"
56
+ }
37
57
  }
@@ -17,16 +17,19 @@ const EventEmitter = require('events').EventEmitter
17
17
  * The Node.js representation of the RTI_Connector_Options structure within
18
18
  * the core.
19
19
  *
20
- * We define it here using the module ref-struct (require above). This allows
20
+ * We define it here using the module ref-struct (require above). This allows
21
21
  * us to pass it by value into the Core when creating a :class:`Connector` object.
22
22
  *
23
23
  * @private
24
24
  */
25
- var _ConnectorOptions = StructType({
25
+ const _ConnectorOptions = StructType({
26
26
  enable_on_data_event: ref.types.int,
27
27
  one_based_sequence_indexing: ref.types.int
28
28
  })
29
29
 
30
+ // We ignore the loading of the libraries in code coverage since it is
31
+ // not easily testable
32
+ /* istanbul ignore next */
30
33
  class _ConnectorBinding {
31
34
  constructor () {
32
35
  let libDir = ''
@@ -36,50 +39,50 @@ class _ConnectorBinding {
36
39
 
37
40
  // Obtain the name of the library that contains the Connector native libraries
38
41
  if (os.arch() === 'arm64') {
39
- if (os.platform() === 'linux') {
40
- libDir = 'linux-arm64'
41
- libName = 'librtiddsconnector.so'
42
- } else {
43
- throw new Error('This platform (' + os.platform() + ' ' + os.arch() + ') is not supported')
44
- }
45
- } else if (os.arch() === 'arm') {
46
- if (os.platform() === 'linux') {
47
- libDir = 'linux-arm'
48
- libName = 'librtiddsconnector.so'
49
- } else {
50
- throw new Error('This platform (' + os.platform() + ' ' + os.arch() + ') is not supported')
51
- }
42
+ if (os.platform() === 'linux') {
43
+ libDir = 'linux-arm64'
44
+ libName = 'librtiddsconnector.so'
45
+ } else {
46
+ throw new Error('This platform (' + os.platform() + ' ' + os.arch() + ') is not supported')
47
+ }
48
+ } else if (os.arch() === 'arm') {
49
+ if (os.platform() === 'linux') {
50
+ libDir = 'linux-arm'
51
+ libName = 'librtiddsconnector.so'
52
+ } else {
53
+ throw new Error('This platform (' + os.platform() + ' ' + os.arch() + ') is not supported')
54
+ }
52
55
  } else {
53
- // Note that we are intentionally not checking if os.arch() is x64.
54
- // This allows somebody with access to 32-bit libraries to replace them
55
- // in the corresponding x64 directory and we will try to load them.
56
- // This behaviour is not officially supported.
57
- switch (os.platform()) {
56
+ // Note that we are intentionally not checking if os.arch() is x64.
57
+ // This allows somebody with access to 32-bit libraries to replace them
58
+ // in the corresponding x64 directory and we will try to load them.
59
+ // This behaviour is not officially supported.
60
+ switch (os.platform()) {
58
61
  case 'darwin':
59
- libDir = 'osx-x64'
60
- libName = 'librtiddsconnector.dylib'
61
- break
62
+ libDir = 'osx-x64'
63
+ libName = 'librtiddsconnector.dylib'
64
+ break
62
65
  case 'linux':
63
- libDir = 'linux-x64'
64
- libName = 'librtiddsconnector.so'
65
- break
66
+ libDir = 'linux-x64'
67
+ libName = 'librtiddsconnector.so'
68
+ break
66
69
  // Windows returns win32 even on 64-bit platforms
67
70
  case 'win32':
68
- libDir = 'win-x64'
69
- libName = 'rtiddsconnector.dll'
70
- additionalLib = 'msvcr120.dll'
71
- isWindows = true
72
- break
71
+ libDir = 'win-x64'
72
+ libName = 'rtiddsconnector.dll'
73
+ additionalLib = 'msvcr120.dll'
74
+ isWindows = true
75
+ break
73
76
  default:
74
- throw new Error(os.platform() + ' not yet supported')
75
- }
77
+ throw new Error(os.platform() + ' not yet supported')
78
+ }
76
79
  }
77
80
 
78
81
  // Connector is not supported on a (non ARM) 32-bit platform
79
82
  // We continue, incase the user has manually replaced the libraries within
80
83
  // the directory which we are going to load.
81
84
  if (os.arch() === 'ia32') {
82
- console.log('Warning: 32-bit ' + os.platform() + ' is not supported')
85
+ console.log('Warning: 32-bit ' + os.platform() + ' is not supported')
83
86
  }
84
87
 
85
88
  if (additionalLib !== null) {
@@ -92,8 +95,8 @@ class _ConnectorBinding {
92
95
 
93
96
  // On Windows we need to explicitly load the dependent libraries
94
97
  if (isWindows) {
95
- ffi.Library(path.join(__dirname, '/rticonnextdds-connector/lib/', libDir, '/', 'nddscore.dll'))
96
- ffi.Library(path.join(__dirname, '/rticonnextdds-connector/lib/', libDir, '/', 'nddsc.dll'))
98
+ ffi.Library(path.join(__dirname, '/rticonnextdds-connector/lib/', libDir, '/', 'nddscore.dll'))
99
+ ffi.Library(path.join(__dirname, '/rticonnextdds-connector/lib/', libDir, '/', 'nddsc.dll'))
97
100
  }
98
101
 
99
102
  this.library = path.join(__dirname, '/rticonnextdds-connector/lib/', libDir, '/', libName)
@@ -138,13 +141,14 @@ class _ConnectorBinding {
138
141
  RTI_Connector_set_max_objects_per_thread: ['int', ['int']],
139
142
  RTIDDSConnector_getJSONInstance:['char *', ['pointer', 'string']],
140
143
  // This API is only used in the unit tests
141
- RTI_Connector_create_test_scenario: ['int', ['pointer', 'int', 'pointer']]
144
+ RTI_Connector_create_test_scenario: ['int', ['pointer', 'int', 'pointer']],
145
+ RTI_Connector_get_build_versions: ['int', [ref.refType('char *'), ref.refType('char *')]]
142
146
  })
143
147
  }
144
148
  }
145
149
 
146
150
  // Create an instance of the connectorBinding class, allowing us to call the FFI'd methods
147
- var connectorBinding = new _ConnectorBinding()
151
+ const connectorBinding = new _ConnectorBinding()
148
152
 
149
153
  /**
150
154
  * Copies a natively allocated string into a Node.js string and frees the
@@ -222,7 +226,7 @@ class TimeoutError extends Error {
222
226
  */
223
227
  class DDSError extends Error {
224
228
  /**
225
- * This error is thrown when an error is encountered from within one of the
229
+ * This error is thrown when an error is encountered from within one of the
226
230
  * APIs within the *RTI Connext DDS* Core.
227
231
  * @private
228
232
  */
@@ -236,7 +240,7 @@ class DDSError extends Error {
236
240
  }
237
241
 
238
242
  /**
239
- * Checks the value returned by the functions in the core for success and
243
+ * Checks the value returned by the functions in the core for success and
240
244
  * throws the appropriate error on failure.
241
245
  *
242
246
  * We do not handle DDS_RETCODE_NO_DATA here, since in some operations (those
@@ -318,13 +322,17 @@ function _getAnyValue (getter, connector, inputName, index, fieldName) {
318
322
  return !!boolVal.deref()
319
323
  } else if (selection === _AnyValueKind.connector_string) {
320
324
  const nodeStr = _moveCString(stringVal.deref())
321
- // Try to convert the returned string to a JSON object. We can now return
322
- // one of two things:
325
+ // If this is NOT a numeric string, try to convert the returned string to a
326
+ // JSON object. We can now return one of two things:
323
327
  // - An actual string (if the JSON.parse call fails)
324
328
  // - A JSON object (if the JSON.parse call succeeds)
325
- try {
326
- return JSON.parse(nodeStr)
327
- } catch (err) {
329
+ if (isNaN(nodeStr)) {
330
+ try {
331
+ return JSON.parse(nodeStr)
332
+ } catch (err) {
333
+ return nodeStr
334
+ }
335
+ } else {
328
336
  return nodeStr
329
337
  }
330
338
  } else {
@@ -336,7 +344,7 @@ function _getAnyValue (getter, connector, inputName, index, fieldName) {
336
344
  /**
337
345
  * Provides access to the meta-data contained in samples read by an input.
338
346
  *
339
- * Note: The Infos class is deprecated and should not be used directly.
347
+ * Note: The Infos class is deprecated and should not be used directly.
340
348
  * Instead, use :meth:`SampleIterator.info`.
341
349
  *
342
350
  * @private
@@ -363,7 +371,7 @@ class Infos {
363
371
  /**
364
372
  * Checks if the sample at the given index contains valid data.
365
373
  *
366
- * @param {number} index - The index of the sample in the :class:`Input`'s
374
+ * @param {number} index - The index of the sample in the :class:`Input`'s
367
375
  * queue to check for valid data
368
376
  * @returns{boolean} True if the sample contains valid data
369
377
  * @private
@@ -399,14 +407,14 @@ class SampleIterator {
399
407
  /**
400
408
  * A SampleIterator provides access to the data receieved by an :class:`Input`.
401
409
  *
402
- * The :attr:`Input.samples` attribute implements a :class:`SampleIterator`,
403
- * meaning it can be iterated over. An individual sample can be accessed
410
+ * The :attr:`Input.samples` attribute implements a :class:`SampleIterator`,
411
+ * meaning it can be iterated over. An individual sample can be accessed
404
412
  * using :meth:`Input.samples.get`.
405
413
  *
406
414
  * See :class:`ValidSampleIterator`.
407
415
  *
408
416
  * This class provides both an iterator and iterable, and is used internally
409
- * by the :class:`Samples` class. The following options to iterate over the
417
+ * by the :class:`Samples` class. The following options to iterate over the
410
418
  * samples exist::
411
419
  *
412
420
  * // option 1 - The iterable can be used in for...of loops
@@ -416,11 +424,11 @@ class SampleIterator {
416
424
  * // option 3 - Returns a generator which must be incremented by the application
417
425
  * const iterator = input.samples.iterator()
418
426
  *
419
- * @property {boolean} validData - Whether or not the current sample
427
+ * @property {boolean} validData - Whether or not the current sample
420
428
  * contains valid data.
421
- * @property {SampleInfo} infos - The meta-data associated with the
429
+ * @property {SampleInfo} infos - The meta-data associated with the
422
430
  * current sample.
423
- * @property {pointer} native - A native handle that allows accessing
431
+ * @property {pointer} native - A native handle that allows accessing
424
432
  * additional *Connext DDS* APIs in C.
425
433
  */
426
434
  constructor (input, index) {
@@ -435,10 +443,10 @@ class SampleIterator {
435
443
  /**
436
444
  * Whether or not this sample contains valid data.
437
445
  *
438
- * If ``false``, the methods to obtain values of the samples
439
- * (e.g., :meth:`SampleIterator.getNumber`,
440
- * :meth:`SampleIterator.getBoolean`, :meth:`SampleIterator.getJson`,
441
- * :meth:`SampleIterator.getString`) should not be called. To avoid
446
+ * If ``false``, the methods to obtain values of the samples
447
+ * (e.g., :meth:`SampleIterator.getNumber`,
448
+ * :meth:`SampleIterator.getBoolean`, :meth:`SampleIterator.getJson`,
449
+ * :meth:`SampleIterator.getString`) should not be called. To avoid
442
450
  * this restraint, use a :class:`ValidSampleIterator`.
443
451
  * @type {boolean}
444
452
  */
@@ -457,17 +465,17 @@ class SampleIterator {
457
465
  *
458
466
  * * ``'source_timestamp'`` returns an integer representing nanoseconds
459
467
  * * ``'reception_timestamp'`` returns an integer representing nanoseconds
460
- * * ``'sample_identity'`` or ``'identity'`` returns a JSON object
468
+ * * ``'sample_identity'`` or ``'identity'`` returns a JSON object
461
469
  * (see :meth:`Output.write`)
462
- * * ``'related_sample_identity'`` returns a JSON object
470
+ * * ``'related_sample_identity'`` returns a JSON object
463
471
  * (see :meth:`Output.write`)
464
- * * ``'valid_data'`` returns a boolean (equivalent to
472
+ * * ``'valid_data'`` returns a boolean (equivalent to
465
473
  * :attr:`SampleIterator.validData`)
466
474
  * * ``'view_state'``, returns a string (either "NEW" or "NOT_NEW")
467
475
  * * ``'instance_state'``, returns a string (one of "ALIVE", "NOT_ALIVE_DISPOSED" or "NOT_ALIVE_NO_WRITERS")
468
476
  * * ``'sample_state'``, returns a string (either "READ" or "NOT_READ")
469
477
  *
470
- * These fields are documented in `The SampleInfo Structure
478
+ * These fields are documented in `The SampleInfo Structure
471
479
  * <https://community.rti.com/static/documentation/connext-dds/current/doc/manuals/connext_dds_professional/users_manual/index.htm#users_manual/The_SampleInfo_Structure.htm>`__
472
480
  * section in the *RTI Connext DDS Core Libraries User's Manual*.
473
481
  *
@@ -482,7 +490,7 @@ class SampleIterator {
482
490
  *
483
491
  * See :ref:`Accessing the data samples`.
484
492
  *
485
- * @param {string} [memberName] - The name of the complex member or field
493
+ * @param {string} [memberName] - The name of the complex member or field
486
494
  * to obtain.
487
495
  * @returns {JSON} The obtained JSON object.
488
496
  */
@@ -493,6 +501,11 @@ class SampleIterator {
493
501
  /**
494
502
  * Gets the value of a numeric field in this sample.
495
503
  *
504
+ * .. note::
505
+ * This operation should not be used with values with an aboslute value
506
+ * larger than `Number.MAX_SAFE_INTEGER`. See :ref:`Accessing 64-bit integers`
507
+ * for more information.
508
+ *
496
509
  * @param {string} fieldName - The name of the field.
497
510
  * @returns {number} The numeric value of the field.
498
511
  */
@@ -579,7 +592,7 @@ class SampleIterator {
579
592
  /**
580
593
  * Iterates and provides access to data samples with valid data.
581
594
  *
582
- * This iterator provides the same methods as :class:`SampleIterator`.
595
+ * This iterator provides the same methods as :class:`SampleIterator`.
583
596
  * It can be obtained using :attr:`Input.samples.validDataIter`.
584
597
  * @extends SampleIterator
585
598
  *
@@ -619,12 +632,12 @@ class ValidSampleIterator extends SampleIterator {
619
632
  */
620
633
  class Samples {
621
634
  /**
622
- * This class provides access to data samples read by an
623
- * :class:`Input` (using either the :meth:`Input.read`
635
+ * This class provides access to data samples read by an
636
+ * :class:`Input` (using either the :meth:`Input.read`
624
637
  * or :meth:`Input.take` methods).
625
638
  *
626
- * This class implements a ``[Symbol.iterator]()`` method, making it an
627
- * iterable. This allows it to be used in ``for... of`` loops, to iterate
639
+ * This class implements a ``[Symbol.iterator]()`` method, making it an
640
+ * iterable. This allows it to be used in ``for... of`` loops, to iterate
628
641
  * through available samples::
629
642
  *
630
643
  * for (const sample of input.samples) {
@@ -639,12 +652,12 @@ class Samples {
639
652
  *
640
653
  * The samples returned by these methods may only contain meta-data
641
654
  * (see :attr:`SampleIterator.info`). The :attr:`Samples.validDataIter`
642
- * iterable only iterates over samples that contain valid data
655
+ * iterable only iterates over samples that contain valid data
643
656
  * (a :class:`ValidSampleIterator`).
644
657
  *
645
- * :class:`Samples` and :class:`ValidSampleIterator` both also provide
646
- * generators to the samples, allowing applications to define their own
647
- * iterables (see :meth:`Samples.iterator()` and
658
+ * :class:`Samples` and :class:`ValidSampleIterator` both also provide
659
+ * generators to the samples, allowing applications to define their own
660
+ * iterables (see :meth:`Samples.iterator()` and
648
661
  * :meth:`ValidSampleIterator.iterator()`).
649
662
  *
650
663
  * ``Samples`` is the type of the property :meth:`Input.samples`.
@@ -652,9 +665,9 @@ class Samples {
652
665
  * For more information and examples, see :ref:`Accessing the data samples`.
653
666
  *
654
667
  * Attributes:
655
- * * length (number) - The number of samples available since the last time
668
+ * * length (number) - The number of samples available since the last time
656
669
  * :meth:`Input.read` or :meth:`Input.take` was called.
657
- * * validDataIter (:class:`ValidSampleIterator`) - The class used to
670
+ * * validDataIter (:class:`ValidSampleIterator`) - The class used to
658
671
  * iterate through the available samples that have valid data.
659
672
  */
660
673
  constructor (input) {
@@ -664,18 +677,18 @@ class Samples {
664
677
  /**
665
678
  * Returns an iterator to the data samples, starting at the index specified.
666
679
  *
667
- * The iterator provides access to all the data samples retrieved by the
680
+ * The iterator provides access to all the data samples retrieved by the
668
681
  * most recent call to :meth:`Input.read` or :meth:`Input.take`.
669
682
  *
670
- * This iterator may return samples with invalid data (samples that only
683
+ * This iterator may return samples with invalid data (samples that only
671
684
  * contain meta-data).
672
- * Use :attr:`Samples.validDataIter` to avoid having to check
685
+ * Use :attr:`Samples.validDataIter` to avoid having to check
673
686
  * :attr:`SampleIterator.validData`.
674
687
  *
675
- * @param {number} [index] The index of the sample from which the iteration
688
+ * @param {number} [index] The index of the sample from which the iteration
676
689
  * should begin. By default, the iterator begins with the first sample.
677
690
  *
678
- * @returns :class:`SampleIterator` - An iterator to the samples (which
691
+ * @returns :class:`SampleIterator` - An iterator to the samples (which
679
692
  * implements both iterable and iterator logic).
680
693
  */
681
694
  get (index) {
@@ -690,7 +703,7 @@ class Samples {
690
703
  *
691
704
  * This iterable may return samples with invalid data (samples that only contain
692
705
  * meta-data).
693
- * Use :attr:`Samples.validDataIter` to avoid having to check
706
+ * Use :attr:`Samples.validDataIter` to avoid having to check
694
707
  * :attr:`SampleIterator.validData`.
695
708
  *
696
709
  * Allows for the following syntax::
@@ -735,13 +748,13 @@ class Samples {
735
748
  * Returns an iterator to the data samples that contain valid data.
736
749
  *
737
750
  * The iterator provides access to all the data samples retrieved by the most
738
- * recent call to :meth:`Input.read` or :meth:`Input.take`, and skips samples
751
+ * recent call to :meth:`Input.read` or :meth:`Input.take`, and skips samples
739
752
  * with invalid data (meta-data only).
740
753
  *
741
754
  * By using this iterator, it is not necessary to check if each sample contains
742
755
  * valid data.
743
756
  *
744
- * @returns {ValidSampleIterator} An iterator to the samples containing valid
757
+ * @returns {ValidSampleIterator} An iterator to the samples containing valid
745
758
  * data (which implements both iterable and iterator logic).
746
759
  */
747
760
  get validDataIter () {
@@ -905,8 +918,8 @@ class Samples {
905
918
  * Gets a JSON object with the values of all the fields of this sample.
906
919
  *
907
920
  * @param {number} index The index of the sample.
908
- * @param {string} [memberName] The name of the complex member. The type
909
- * of the member with name memberName must be an array, sequence, struct,
921
+ * @param {string} [memberName] The name of the complex member. The type
922
+ * of the member with name memberName must be an array, sequence, struct,
910
923
  * value or union.
911
924
  * @returns {JSON} The obtained JSON object.
912
925
  *
@@ -949,10 +962,10 @@ class Samples {
949
962
  }
950
963
 
951
964
  /**
952
- * Obtains a native handle to the sample, which can be used to access
965
+ * Obtains a native handle to the sample, which can be used to access
953
966
  * additional *Connext DDS* APIs in C.
954
967
  *
955
- * @param {number} index The index of the sample for which to obtain
968
+ * @param {number} index The index of the sample for which to obtain
956
969
  * the native pointer.
957
970
  * @returns {pointer} A native pointer to the sample.
958
971
  */
@@ -972,9 +985,9 @@ class Samples {
972
985
  /**
973
986
  * This method is deprecated, use :meth:`Samples.getJson`.
974
987
  *
975
- * @param {number} index - The index of the sample for which to obtain
988
+ * @param {number} index - The index of the sample for which to obtain
976
989
  * the JSON object.
977
- * @param {string} [memberName] - The name of the complex member for
990
+ * @param {string} [memberName] - The name of the complex member for
978
991
  * which to obtain the JSON object.
979
992
  * @returns {JSON} A JSON object representing the current sample.
980
993
  * @private
@@ -1003,14 +1016,14 @@ class SampleInfo {
1003
1016
  *
1004
1017
  * * ``'source_timestamp'`` returns an integer representing nanoseconds
1005
1018
  * * ``'reception_timestamp'`` returns an integer representing nanoseconds
1006
- * * ``'sample_identity'`` or ``'identity'`` returns a JSON object
1019
+ * * ``'sample_identity'`` or ``'identity'`` returns a JSON object
1007
1020
  * (see :meth:`Output.write`)
1008
- * * ``'related_sample_identity'`` returns a JSON object
1021
+ * * ``'related_sample_identity'`` returns a JSON object
1009
1022
  * (see :meth:`Output.write`)
1010
- * * ``'valid_data'`` returns a boolean (equivalent to
1023
+ * * ``'valid_data'`` returns a boolean (equivalent to
1011
1024
  * :attr:`SampleIterator.validData`)
1012
1025
  *
1013
- * These fields are documented in `The SampleInfo Structure
1026
+ * These fields are documented in `The SampleInfo Structure
1014
1027
  * <https://community.rti.com/static/documentation/connext-dds/current/doc/manuals/connext_dds_professional/users_manual/index.htm#users_manual/The_SampleInfo_Structure.htm>`__
1015
1028
  * section in the *RTI Connext DDS Core Libraries User's Manual*.
1016
1029
  *
@@ -1043,11 +1056,11 @@ class Input {
1043
1056
  *
1044
1057
  * Attributes:
1045
1058
  * * connector (:class:`Connector`) - The Connector creates this Input.
1046
- * * name (string) - The name of the Input (the name used in
1059
+ * * name (string) - The name of the Input (the name used in
1047
1060
  * :meth:`Connector.getInput`).
1048
- * * native (pointer) - A native handle that allows accessing additional
1061
+ * * native (pointer) - A native handle that allows accessing additional
1049
1062
  * *Connext DDS* APIs in C.
1050
- * * matchedPublications (JSON) - A JSON object containing information
1063
+ * * matchedPublications (JSON) - A JSON object containing information
1051
1064
  * about all the publications currently matched with this Input.
1052
1065
  */
1053
1066
  constructor (connector, name) {
@@ -1075,8 +1088,8 @@ class Input {
1075
1088
  /**
1076
1089
  * Accesses the samples received by this Input.
1077
1090
  *
1078
- * This operation performs the same operation as :meth:`Input.take` but
1079
- * the samples remain accessible (in the internal queue) after the
1091
+ * This operation performs the same operation as :meth:`Input.take` but
1092
+ * the samples remain accessible (in the internal queue) after the
1080
1093
  * operation has been called.
1081
1094
  */
1082
1095
  read () {
@@ -1088,7 +1101,7 @@ class Input {
1088
1101
  /**
1089
1102
  * Accesses the samples receieved by this Input.
1090
1103
  *
1091
- * After calling this method, the samples are accessible using
1104
+ * After calling this method, the samples are accessible using
1092
1105
  * :meth:`Input.samples`.
1093
1106
  */
1094
1107
  take () {
@@ -1115,18 +1128,18 @@ class Input {
1115
1128
  * .. note::
1116
1129
  * This operation is asynchronous.
1117
1130
  *
1118
- * This method waits for the specified timeout (or if no timeout is
1131
+ * This method waits for the specified timeout (or if no timeout is
1119
1132
  * specified, it waits forever), for a match (or unmatch) to occur.
1120
- * @param {number} [timeout] The maximum time to wait, in milliseconds.
1133
+ * @param {number} [timeout] The maximum time to wait, in milliseconds.
1121
1134
  * By default, infinite.
1122
- * @throws {TimeoutError} :class:`TimeoutError` will be thrown if the
1135
+ * @throws {TimeoutError} :class:`TimeoutError` will be thrown if the
1123
1136
  * timeout expires before any publications are matched.
1124
- * @returns {Promise} Promise object resolving with the change in the
1125
- * current number of matched outputs. If this is a positive number,
1126
- * the input has matched with new publishers. If it is negative, the
1127
- * input has unmatched from an output. It is possible for multiple
1128
- * matches and/or unmatches to be returned (e.g., 0 could be returned,
1129
- * indicating that the input matched the same number of outputs as it
1137
+ * @returns {Promise} Promise object resolving with the change in the
1138
+ * current number of matched outputs. If this is a positive number,
1139
+ * the input has matched with new publishers. If it is negative, the
1140
+ * input has unmatched from an output. It is possible for multiple
1141
+ * matches and/or unmatches to be returned (e.g., 0 could be returned,
1142
+ * indicating that the input matched the same number of outputs as it
1130
1143
  * unmatched).
1131
1144
  */
1132
1145
  waitForPublications (timeout) {
@@ -1165,15 +1178,15 @@ class Input {
1165
1178
  /**
1166
1179
  * Returns information about matched publications.
1167
1180
  *
1168
- * This property returns a JSON array, with each element of the
1181
+ * This property returns a JSON array, with each element of the
1169
1182
  * array containing information about a matched publication.
1170
1183
  *
1171
- * Currently the only information contained in this JSON object is
1172
- * the publication name of the matched publication. If the matched
1173
- * publication doesn't have a name, the name for that specific
1184
+ * Currently the only information contained in this JSON object is
1185
+ * the publication name of the matched publication. If the matched
1186
+ * publication doesn't have a name, the name for that specific
1174
1187
  * publication will be null.
1175
1188
  *
1176
- * Note that :class:`Connector` Outputs are automatically assigned
1189
+ * Note that :class:`Connector` Outputs are automatically assigned
1177
1190
  * a name from the ``data_writer name`` element in the XML configuration.
1178
1191
  *
1179
1192
  * @type {JSON}
@@ -1193,11 +1206,11 @@ class Input {
1193
1206
  * .. note::
1194
1207
  * This operation is asynchronous.
1195
1208
  *
1196
- * @param {number} [timeout] The maximum time to wait, in milliseconds.
1209
+ * @param {number} [timeout] The maximum time to wait, in milliseconds.
1197
1210
  * By default, infinite.
1198
- * @throws {TimeoutError} :class:`TimeoutError` will be thrown if the
1211
+ * @throws {TimeoutError} :class:`TimeoutError` will be thrown if the
1199
1212
  * timeout expires before data is received.
1200
- * @returns {Promise} A ``Promise`` which will be resolved once data is
1213
+ * @returns {Promise} A ``Promise`` which will be resolved once data is
1201
1214
  * available, or rejected if the timeout expires.
1202
1215
  */
1203
1216
  wait (timeout) {
@@ -1236,17 +1249,17 @@ class Instance {
1236
1249
  /**
1237
1250
  * A data sample.
1238
1251
  *
1239
- * :class:`Instance` is the type obtained through ``Output.instance``
1252
+ * :class:`Instance` is the type obtained through ``Output.instance``
1240
1253
  * and is the object that is published by :meth:`Output.write`.
1241
1254
  *
1242
- * An Instance has an associated DDS Type, specified in the XML
1243
- * configuration, and it allows setting the values for the fields of
1255
+ * An Instance has an associated DDS Type, specified in the XML
1256
+ * configuration, and it allows setting the values for the fields of
1244
1257
  * the DDS Type.
1245
1258
  *
1246
1259
  * Attributes:
1247
- * * ``output`` (:class:`Output`) - The :class:`Output` that owns
1260
+ * * ``output`` (:class:`Output`) - The :class:`Output` that owns
1248
1261
  * this Instance.
1249
- * * ``native`` (pointer) - Native handle to this Instance that allows
1262
+ * * ``native`` (pointer) - Native handle to this Instance that allows
1250
1263
  * for additional *Connext DDS Pro* C APIs to be called.
1251
1264
  */
1252
1265
  constructor (output) {
@@ -1256,9 +1269,9 @@ class Instance {
1256
1269
  /**
1257
1270
  * Resets a member to its default value.
1258
1271
  *
1259
- * The effect is the same as that of :meth:`Output.clearMembers`, except
1272
+ * The effect is the same as that of :meth:`Output.clearMembers`, except
1260
1273
  * that only one member is cleared.
1261
- * @param {string} fieldName The name of the field. It can be a complex
1274
+ * @param {string} fieldName The name of the field. It can be a complex
1262
1275
  * member or a primitive member.
1263
1276
  */
1264
1277
  clearMember (fieldName) {
@@ -1276,8 +1289,13 @@ class Instance {
1276
1289
  /**
1277
1290
  * Sets a numeric field.
1278
1291
  *
1292
+ * .. note::
1293
+ * This operation should not be used with values with an aboslute value
1294
+ * larger than `Number.MAX_SAFE_INTEGER`. See :ref:`Accessing 64-bit integers`
1295
+ * for more information.
1296
+ *
1279
1297
  * @param {string} fieldName - The name of the field.
1280
- * @param {number} value - A numeric value, or null, to unset an
1298
+ * @param {number} value - A numeric value, or null, to unset an
1281
1299
  * optional member.
1282
1300
  */
1283
1301
  setNumber (fieldName, value) {
@@ -1302,7 +1320,7 @@ class Instance {
1302
1320
  * Sets a boolean field.
1303
1321
  *
1304
1322
  * @param {string} fieldName - The name of the field.
1305
- * @param {boolean} value - A boolean value, or null, to unset an
1323
+ * @param {boolean} value - A boolean value, or null, to unset an
1306
1324
  * optional member.
1307
1325
  */
1308
1326
  setBoolean (fieldName, value) {
@@ -1328,7 +1346,7 @@ class Instance {
1328
1346
  * Sets a string field.
1329
1347
  *
1330
1348
  * @param {string} fieldName - The name of the field.
1331
- * @param {number} value - A string value, or null, to unset an
1349
+ * @param {string|null} value - A string value, or null, to unset an
1332
1350
  * optional member.
1333
1351
  */
1334
1352
  setString (fieldName, value) {
@@ -1353,20 +1371,20 @@ class Instance {
1353
1371
  /**
1354
1372
  * Sets the member values specified in a JSON object.
1355
1373
  *
1356
- * The keys in the JSON object are the member names of the DDS Type
1357
- * associated with the Output, and the values are the values to set
1374
+ * The keys in the JSON object are the member names of the DDS Type
1375
+ * associated with the Output, and the values are the values to set
1358
1376
  * for those members.
1359
1377
  *
1360
- * This method sets the values of those members that are explicitly
1361
- * specified in the JSON object. Any member that is not specified in
1378
+ * This method sets the values of those members that are explicitly
1379
+ * specified in the JSON object. Any member that is not specified in
1362
1380
  * the JSON object will retain its previous value.
1363
1381
  *
1364
- * To clear members that are not in the JSON object, call
1365
- * :meth:`Output.clearMembers` before this method. You can also
1366
- * explicitly set any value in the JSON object to *null* to reset that
1382
+ * To clear members that are not in the JSON object, call
1383
+ * :meth:`Output.clearMembers` before this method. You can also
1384
+ * explicitly set any value in the JSON object to *null* to reset that
1367
1385
  * field to its default value.
1368
1386
  *
1369
- * @param {JSON} jsonObj - The JSON object containing the keys
1387
+ * @param {JSON} jsonObj - The JSON object containing the keys
1370
1388
  * (field names) and values (values for the fields).
1371
1389
  */
1372
1390
  setFromJson (jsonObj) {
@@ -1379,16 +1397,16 @@ class Instance {
1379
1397
  /**
1380
1398
  * Sets the value of fieldName.
1381
1399
  *
1382
- * The type of the argument ``value`` must correspond with the type of the
1400
+ * The type of the argument ``value`` must correspond with the type of the
1383
1401
  * field with name ``fieldName`` (as defined in the configuration XML file).
1384
1402
  *
1385
- * This method is an alternative to
1386
- * :meth:`Instance.setNumber`, :meth:`Instance.setString` and
1387
- * :meth:`Instance.setBoolean`. The main difference is that it is
1403
+ * This method is an alternative to
1404
+ * :meth:`Instance.setNumber`, :meth:`Instance.setString` and
1405
+ * :meth:`Instance.setBoolean`. The main difference is that it is
1388
1406
  * type-independent (in that the same method can be used for all fields).
1389
1407
  *
1390
1408
  * @param {string} fieldName The name of the field.
1391
- * @param {number|boolean|string|null} value The value to set. Note that
1409
+ * @param {number|boolean|string|null} value The value to set. Note that
1392
1410
  * ``null`` is used to unset an optional member.
1393
1411
  */
1394
1412
  set (fieldName, value) {
@@ -1417,17 +1435,22 @@ class Instance {
1417
1435
  /**
1418
1436
  * Retrives the value of this instance as a JSON object.
1419
1437
  *
1438
+ * .. note::
1439
+ * This operation should not be used with values with an aboslute value
1440
+ * larger than `Number.MAX_SAFE_INTEGER`. See :ref:`Accessing 64-bit integers`
1441
+ * for more information.
1442
+ *
1420
1443
  * @returns {JSON} The value of this instance as a JSON object.
1421
1444
  */
1422
1445
  getJson () {
1423
1446
  const nativeStr = connectorBinding.api.RTIDDSConnector_getJSONInstance(
1424
- this.output.connector.native,
1425
- this.output.name)
1447
+ this.output.connector.native,
1448
+ this.output.name)
1426
1449
  // Now move the native string
1427
1450
  if (nativeStr === null) {
1428
- throw new Error('Failed to create JSON object of instance')
1451
+ throw new Error('Failed to create JSON object of instance')
1429
1452
  } else {
1430
- return JSON.parse(_moveCString(nativeStr))
1453
+ return JSON.parse(_moveCString(nativeStr))
1431
1454
  }
1432
1455
  }
1433
1456
 
@@ -1467,15 +1490,15 @@ class Output {
1467
1490
  * To get an Output object, use :meth:`Connector.getOutput`.
1468
1491
  *
1469
1492
  * Attributes:
1470
- * * ``instance`` (:class:`Instance`) - The data that is written when
1493
+ * * ``instance`` (:class:`Instance`) - The data that is written when
1471
1494
  * :meth:`Output.write` is called.
1472
- * * ``connector`` (:class:`Connector`) - The :class:`Connector` object
1495
+ * * ``connector`` (:class:`Connector`) - The :class:`Connector` object
1473
1496
  * that created this object.
1474
- * * ``name`` (str) - The name of this Output (the name used in
1497
+ * * ``name`` (str) - The name of this Output (the name used in
1475
1498
  * :meth:`Connector.getOutput`).
1476
- * * ``native`` (pointer) - The native handle that allows accessing
1499
+ * * ``native`` (pointer) - The native handle that allows accessing
1477
1500
  * additional *Connext DDS* APIs in C.
1478
- * * ``matchedSubscriptions`` (JSON) - Information about matched
1501
+ * * ``matchedSubscriptions`` (JSON) - Information about matched
1479
1502
  * subscriptions (see below).
1480
1503
  *
1481
1504
  */
@@ -1495,40 +1518,40 @@ class Output {
1495
1518
  /**
1496
1519
  * Publishes the values of the current Instance.
1497
1520
  *
1498
- * Note that after writing it, the Instance's values remain unchanged.
1499
- * If, for the next write, you need to start from scratch, you must
1521
+ * Note that after writing it, the Instance's values remain unchanged.
1522
+ * If, for the next write, you need to start from scratch, you must
1500
1523
  * first call :meth:`Output.clearMembers`.
1501
1524
  *
1502
- * This method accepts an optional JSON object as a parameter, which may
1525
+ * This method accepts an optional JSON object as a parameter, which may
1503
1526
  * specify the parameters to use in the `write` call.
1504
- * The supported parameters are a subset of those documented in the
1527
+ * The supported parameters are a subset of those documented in the
1505
1528
  * `Writing Data section <https://community.rti.com/static/documentation/connext-dds/current/doc/manuals/connext_dds_professional/users_manual/index.htm#users_manual/Writing_Data.htm?Highlight=DDS_WriteParams_t>`__
1506
1529
  * of the *RTI Connext DDS Core Libraries User's Manual*. These are:
1507
1530
  *
1508
1531
  * * ``action`` – One of ``write`` (default), ``dispose`` or ``unregister``
1509
- * * ``source_timestamp`` – An integer representing the total number of
1532
+ * * ``source_timestamp`` – An integer representing the total number of
1510
1533
  * nanoseconds
1511
- * * ``identity`` – A JSON object containing the fields ``writer_guid`` and
1534
+ * * ``identity`` – A JSON object containing the fields ``writer_guid`` and
1512
1535
  * ``sequence_number``
1513
- * * ``related_sample_identity`` – Used for request-reply communications.
1536
+ * * ``related_sample_identity`` – Used for request-reply communications.
1514
1537
  * It has the same format as identity
1515
1538
  *
1516
1539
  * @example output.write()
1517
- * @example output.write({
1518
- * action: 'dispose',
1519
- * identity: { writer_guid: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16], sequence_number: 1 }
1540
+ * @example output.write({
1541
+ * action: 'dispose',
1542
+ * identity: { writer_guid: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16], sequence_number: 1 }
1520
1543
  * })
1521
1544
  *
1522
1545
  * @param {JSON} [params] [Optional] The optional parameters described above
1523
- * @throws {TimeoutError} The write method can block under multiple
1524
- * circumstances (see 'Blocking During a write()' in the `Writing Data section
1546
+ * @throws {TimeoutError} The write method can block under multiple
1547
+ * circumstances (see 'Blocking During a write()' in the `Writing Data section
1525
1548
  * <https://community.rti.com/static/documentation/connext-dds/current/doc/manuals/connext_dds_professional/users_manual/index.htm#users_manual/Writing_Data.htm>`__
1526
1549
  * of the *RTI Connext DDS Core Libraries User's Manual*.)
1527
- * If the blocking time exceeds the ``max_blocking_time``, this method
1550
+ * If the blocking time exceeds the ``max_blocking_time``, this method
1528
1551
  * throws :class:`TimeoutError`.
1529
1552
  */
1530
1553
  write (params) {
1531
- var cStr
1554
+ let cStr
1532
1555
  if (params === undefined) {
1533
1556
  cStr = null
1534
1557
  } else {
@@ -1543,10 +1566,10 @@ class Output {
1543
1566
  /**
1544
1567
  * Resets the values of the members of this :class:`Instance`.
1545
1568
  *
1546
- * If the member is defined with a *default* attribute in the configuration
1547
- * file, it gets that value. Otherwise, numbers are set to 0 and strings are
1569
+ * If the member is defined with a *default* attribute in the configuration
1570
+ * file, it gets that value. Otherwise, numbers are set to 0 and strings are
1548
1571
  * set to empty. Sequences are cleared and optional members are set to 'null'.
1549
- * For example, if this Output's type is *ShapeType*, then ``clearMembers()``
1572
+ * For example, if this Output's type is *ShapeType*, then ``clearMembers()``
1550
1573
  * sets::
1551
1574
  * color = 'RED'
1552
1575
  * shapesize = 30
@@ -1560,7 +1583,7 @@ class Output {
1560
1583
  }
1561
1584
 
1562
1585
  /**
1563
- * Waits until all matching reliable subscriptions have acknowledged all the
1586
+ * Waits until all matching reliable subscriptions have acknowledged all the
1564
1587
  * samples that have currently been written.
1565
1588
  *
1566
1589
  * This method only waits if this Output is configured with a reliable QoS.
@@ -1568,13 +1591,13 @@ class Output {
1568
1591
  * .. note::
1569
1592
  * This operation is asynchronous
1570
1593
  *
1571
- * @param {timeout} [timeout] The maximum time to wait, in milliseconds.
1594
+ * @param {timeout} [timeout] The maximum time to wait, in milliseconds.
1572
1595
  * By default, infinite.
1573
1596
  * @throws {TimeoutError} :class:`TimeoutError` will be thrown if the timeout
1574
- * expires before all matching reliable subscriptions acknowledge all the
1597
+ * expires before all matching reliable subscriptions acknowledge all the
1575
1598
  * samples.
1576
- * @returns {Promise} Promise object which will be rejected if not all matching
1577
- * reliable subscriptions acknowledge all of the samples within the specified
1599
+ * @returns {Promise} Promise object which will be rejected if not all matching
1600
+ * reliable subscriptions acknowledge all of the samples within the specified
1578
1601
  * timeout.
1579
1602
  */
1580
1603
  wait (timeout) {
@@ -1589,10 +1612,14 @@ class Output {
1589
1612
  timeout,
1590
1613
  (err, res) => {
1591
1614
  if (err) {
1592
- reject(err)
1615
+ return reject(err)
1616
+ } else if (res === _ReturnCodes.ok) {
1617
+ return resolve()
1618
+ } else if (res === _ReturnCodes.timeout) {
1619
+ return reject(new TimeoutError('Timeout error'))
1620
+ } else {
1621
+ return reject(new DDSError('res: ' + res))
1593
1622
  }
1594
- _checkRetcode(res)
1595
- resolve()
1596
1623
  }
1597
1624
  )
1598
1625
  })
@@ -1601,21 +1628,21 @@ class Output {
1601
1628
  /**
1602
1629
  * Waits for this Output to match or unmatch a compatible DDS Publication.
1603
1630
  *
1604
- * This method waits for the specified timeout (or if no timeout is
1631
+ * This method waits for the specified timeout (or if no timeout is
1605
1632
  * specified, it waits forever), for a match (or unmatch) to occur.
1606
1633
  *
1607
1634
  * .. note::
1608
1635
  * This operation is asynchronous
1609
1636
  *
1610
- * @param {number} [timeout] - The maximum time to wait, in milliseconds.
1637
+ * @param {number} [timeout] - The maximum time to wait, in milliseconds.
1611
1638
  * By default, infinite.
1612
- * @throws {TimeoutError} :class:`TimeoutError` will be thrown if the
1639
+ * @throws {TimeoutError} :class:`TimeoutError` will be thrown if the
1613
1640
  * timeout expires before a subscription is matched.
1614
- * @returns {Promise} Promise object resolving with the change in the
1615
- * current number of matched inputs. If this is a positive number, the
1616
- * output has matched with new subscribers. If it is negative, the output
1617
- * has unmatched from a subscription. It is possible for multiple matches
1618
- * and/or unmatches to be returned (e.g., 0 could be returned, indicating
1641
+ * @returns {Promise} Promise object resolving with the change in the
1642
+ * current number of matched inputs. If this is a positive number, the
1643
+ * output has matched with new subscribers. If it is negative, the output
1644
+ * has unmatched from a subscription. It is possible for multiple matches
1645
+ * and/or unmatches to be returned (e.g., 0 could be returned, indicating
1619
1646
  * that the output matched the same number of inputs as it unmatched).
1620
1647
  */
1621
1648
  waitForSubscriptions (timeout) {
@@ -1643,7 +1670,7 @@ class Output {
1643
1670
  } else if (res === _ReturnCodes.timeout) {
1644
1671
  return reject(new TimeoutError('Timeout error'))
1645
1672
  } else {
1646
- return reject(new DDSError('DDS error'))
1673
+ return reject(new DDSError('res: ' + res))
1647
1674
  }
1648
1675
  }
1649
1676
  )
@@ -1654,14 +1681,14 @@ class Output {
1654
1681
  /**
1655
1682
  * Provides information about matched subscriptions.
1656
1683
  *
1657
- * This property returns a JSON array, with each element of the array
1684
+ * This property returns a JSON array, with each element of the array
1658
1685
  * containing information about a matched subscription.
1659
1686
  *
1660
- * Currently the only information contained in this JSON object is the
1687
+ * Currently the only information contained in this JSON object is the
1661
1688
  * subscription name of the matched subscription. If the matched subscription
1662
1689
  * doesn't have a name, the name for that specific subscription will be null.
1663
1690
  *
1664
- * Note that :class:`Connector` Inputs are automatically assigned a name from
1691
+ * Note that :class:`Connector` Inputs are automatically assigned a name from
1665
1692
  * the ``data_reader name`` element in the XML configuration.
1666
1693
  *
1667
1694
  * @type {JSON}
@@ -1675,6 +1702,7 @@ class Output {
1675
1702
  return JSON.parse(_moveCString(cStr.deref()))
1676
1703
  }
1677
1704
 
1705
+ /* istanbul ignore next */
1678
1706
  // Deprecated, use clearMembers
1679
1707
  clear_members () { // eslint-disable-line camelcase
1680
1708
  return this.clearMembers()
@@ -1685,9 +1713,9 @@ class Output {
1685
1713
  * Loads a configuration and creates its Inputs and Outputs.
1686
1714
  *
1687
1715
  * .. note::
1688
- * The :class:`Connector` class inherits from
1716
+ * The :class:`Connector` class inherits from
1689
1717
  * `EventEmitter <https://nodejs.org/api/events.html#events_class_eventemitter>`__.
1690
- * This allows us to support event-based notification for data, using the
1718
+ * This allows us to support event-based notification for data, using the
1691
1719
  * following syntax:
1692
1720
  *
1693
1721
  * .. code-block:: javascript
@@ -1696,32 +1724,32 @@ class Output {
1696
1724
  *
1697
1725
  * Please refer to :ref:`Reading data (Input)` for more information.
1698
1726
  *
1699
- * A :class:`Connector` instance loads a configuration file from an XML
1727
+ * A :class:`Connector` instance loads a configuration file from an XML
1700
1728
  * document. For example::
1701
1729
  * const connector = new rti.Connector('MyParticipantLibrary::MyParticipant', 'MyExample.xml')
1702
1730
  *
1703
- * After creating it, the :class:`Connector` object's Inputs can be used to
1704
- * read data, and the Outputs to write data. The methods
1705
- * :meth:`Connector.getOutput` and :meth:`Connector.getInput` return an
1731
+ * After creating it, the :class:`Connector` object's Inputs can be used to
1732
+ * read data, and the Outputs to write data. The methods
1733
+ * :meth:`Connector.getOutput` and :meth:`Connector.getInput` return an
1706
1734
  * :class:`Input` and :class:`Output`, respectively.
1707
1735
  *
1708
- * An application can create multiple :class:`Connector` instances for the
1736
+ * An application can create multiple :class:`Connector` instances for the
1709
1737
  * same or different configurations.
1710
1738
  */
1711
1739
  class Connector extends EventEmitter {
1712
1740
  /**
1713
- * @arg {string} configName The configuration to load. The configName format
1714
- * is `LibraryName::ParticipantName`, where LibraryName is the name
1715
- * attribute of a ``<domain_participant_library>`` tag, and
1716
- * ParticipantName is the name attribute of a ``<domain_participant>`` tag
1741
+ * @arg {string} configName The configuration to load. The configName format
1742
+ * is `LibraryName::ParticipantName`, where LibraryName is the name
1743
+ * attribute of a ``<domain_participant_library>`` tag, and
1744
+ * ParticipantName is the name attribute of a ``<domain_participant>`` tag
1717
1745
  * within that library.
1718
- * @arg {string} url A URL locating the XML document. It can be a file path
1719
- * (e.g., ``/tmp/my_dds_config.xml``), a string containing the full XML
1746
+ * @arg {string} url A URL locating the XML document. It can be a file path
1747
+ * (e.g., ``/tmp/my_dds_config.xml``), a string containing the full XML
1720
1748
  * document with the following format: ``str://"<dds>...</dds>"``, or a
1721
- * combination of multiple files or strings, as explained in the
1749
+ * combination of multiple files or strings, as explained in the
1722
1750
  * `URL Groups <https://community.rti.com/static/documentation/connext-dds/current/doc/manuals/connext_dds_professional/users_manual/index.htm#users_manual/URL_Groups.htm>`__
1723
1751
  * section of the *Connext DDS Core Libraries User's Manual*.
1724
- *
1752
+ *
1725
1753
  */
1726
1754
  constructor (configName, url) {
1727
1755
  super()
@@ -1742,18 +1770,18 @@ class Connector extends EventEmitter {
1742
1770
  }
1743
1771
 
1744
1772
  /**
1745
- * This method is used internally by the public APIs
1746
- * :meth:`Connector.close` and
1773
+ * This method is used internally by the public APIs
1774
+ * :meth:`Connector.close` and
1747
1775
  * :meth:`Connector.waitForCallbackFinalization`. It should not be used
1748
1776
  * directly by applications.
1749
1777
  *
1750
- * @param {function} resolve The resolve() callback to call once waitSetBusy
1778
+ * @param {function} resolve The resolve() callback to call once waitSetBusy
1751
1779
  * is false.
1752
- * @param {function} reject The reject() callback to call if we timeout,
1780
+ * @param {function} reject The reject() callback to call if we timeout,
1753
1781
  * or if another error occurs.
1754
- * @param {number} iterations Maximum number of iterations to perform
1782
+ * @param {number} iterations Maximum number of iterations to perform
1755
1783
  * before timing out.
1756
- * @param {boolean} cleanup Whether or not the :class:`Connector` object
1784
+ * @param {boolean} cleanup Whether or not the :class:`Connector` object
1757
1785
  * should be deleted once the waitset is no longer busy.
1758
1786
  * @private
1759
1787
  */
@@ -1783,27 +1811,27 @@ class Connector extends EventEmitter {
1783
1811
  * by the :class:`Connector` are no longer in use.
1784
1812
  *
1785
1813
  * .. note::
1786
- * This returned promise will be rejected if there are any listeners
1787
- * registered for the ``on_data_available`` event. Ensure that they have
1788
- * all been removed before calling this method using
1814
+ * This returned promise will be rejected if there are any listeners
1815
+ * registered for the ``on_data_available`` event. Ensure that they have
1816
+ * all been removed before calling this method using
1789
1817
  * ``connector.removeAllListeners(on_data_available)``.
1790
1818
  *
1791
- * It is currently only necessary to call this method if you remove all of
1819
+ * It is currently only necessary to call this method if you remove all of
1792
1820
  * the listeners for the ``on_data_available`` event and at some point in the
1793
- * future wish to use the same :class:`Connector` object to get notifications
1794
- * of new data (via the :meth:`Connector.wait` method, or by re-adding a
1821
+ * future wish to use the same :class:`Connector` object to get notifications
1822
+ * of new data (via the :meth:`Connector.wait` method, or by re-adding a
1795
1823
  * listener for the ``on_data_available`` event).
1796
1824
  *
1797
- * This operation does **not** free any resources. It is still necessary to
1798
- * call :meth:`Connector.close` when the :class:`Connector` is no longer
1825
+ * This operation does **not** free any resources. It is still necessary to
1826
+ * call :meth:`Connector.close` when the :class:`Connector` is no longer
1799
1827
  * required.
1800
1828
  *
1801
- * @argument {number} [timeout] Optional parameter to indicate the timeout
1802
- * of the operation, in seconds. By default, 10s. If this operation does
1803
- * not complete within the specified timeout, the returned Promise will
1829
+ * @argument {number} [timeout] Optional parameter to indicate the timeout
1830
+ * of the operation, in seconds. By default, 10s. If this operation does
1831
+ * not complete within the specified timeout, the returned Promise will
1804
1832
  * be rejected.
1805
- * @returns {Promise} A Promise that will be resolved once the resources
1806
- * being used internally by the :class:`Connector` object are no longer
1833
+ * @returns {Promise} A Promise that will be resolved once the resources
1834
+ * being used internally by the :class:`Connector` object are no longer
1807
1835
  * in use.
1808
1836
  */
1809
1837
  waitForCallbackFinalization (timeout) {
@@ -1819,12 +1847,12 @@ class Connector extends EventEmitter {
1819
1847
  /**
1820
1848
  * Frees all the resources created by this :class:`Connector` instance.
1821
1849
  *
1822
- * @argument {number} [timeout] Optional parameter to indicate the timeout
1823
- * of the operation, in seconds. By default, 10s. If this operation does
1824
- * not complete within the specified timeout, the returned Promise will
1850
+ * @argument {number} [timeout] Optional parameter to indicate the timeout
1851
+ * of the operation, in seconds. By default, 10s. If this operation does
1852
+ * not complete within the specified timeout, the returned Promise will
1825
1853
  * be rejected.
1826
- * @returns {Promise} Which resolves once the :class:`Connector` object has
1827
- * been freed. It is only necessary to wait for this promise to resolve
1854
+ * @returns {Promise} Which resolves once the :class:`Connector` object has
1855
+ * been freed. It is only necessary to wait for this promise to resolve
1828
1856
  * if you have attached a listener for the ``on_data_available`` event.
1829
1857
  */
1830
1858
  close (timeout) {
@@ -1851,7 +1879,7 @@ class Connector extends EventEmitter {
1851
1879
  /**
1852
1880
  * Returns the :class:`Input` named inputName.
1853
1881
  *
1854
- * ``inputName`` identifies a ``<data_reader>`` tag in the configuration
1882
+ * ``inputName`` identifies a ``<data_reader>`` tag in the configuration
1855
1883
  * loaded by the :class:`Connector`. For example::
1856
1884
  *
1857
1885
  * const connector = new rti.Connector('MyParticipantLibrary::MyParticipant', 'MyExample.xml')
@@ -1872,7 +1900,7 @@ class Connector extends EventEmitter {
1872
1900
  * ...
1873
1901
  * <domain_participant_library>
1874
1902
  *
1875
- * @param {string} inputName The name of the ``data_reader`` to load, with the
1903
+ * @param {string} inputName The name of the ``data_reader`` to load, with the
1876
1904
  * format `SubscriberName::DataReaderName`.
1877
1905
  * @returns {Input} The Input, if it exists.
1878
1906
  */
@@ -1883,7 +1911,7 @@ class Connector extends EventEmitter {
1883
1911
  /**
1884
1912
  * Returns the :class:`Output` named outputName.
1885
1913
  *
1886
- * ``outputName`` identifies a ``<data_writer>`` tag in the configuration
1914
+ * ``outputName`` identifies a ``<data_writer>`` tag in the configuration
1887
1915
  * loaded by the :class:`Connector`. For example::
1888
1916
  *
1889
1917
  * const connector = new rti.Connector('MyParticipantLibrary::MyParticipant', 'MyExample.xml')
@@ -1904,7 +1932,7 @@ class Connector extends EventEmitter {
1904
1932
  * ...
1905
1933
  * <domain_participant_library>
1906
1934
  *
1907
- * @param {string} outputName The name of the ``data_writer`` to load, with
1935
+ * @param {string} outputName The name of the ``data_writer`` to load, with
1908
1936
  * the format ``PublisherName::DataWriterName``.
1909
1937
  * @returns {Output} The Output, if it exists.
1910
1938
  */
@@ -1918,11 +1946,11 @@ class Connector extends EventEmitter {
1918
1946
  * .. note::
1919
1947
  * This operation is asynchronous.
1920
1948
  *
1921
- * @param {number} timeout The maximum time to wait, in milliseconds.
1949
+ * @param {number} timeout The maximum time to wait, in milliseconds.
1922
1950
  * By default, infinite.
1923
- * @throws {TimeoutError} :class:`TimeoutError` will be thrown if the
1951
+ * @throws {TimeoutError} :class:`TimeoutError` will be thrown if the
1924
1952
  * timeout expires before data is received.
1925
- * @returns {Promise} A ``Promise`` which will be resolved once data
1953
+ * @returns {Promise} A ``Promise`` which will be resolved once data
1926
1954
  * is available, or rejected once the timeout expires.
1927
1955
  */
1928
1956
  wait (timeout) {
@@ -1957,17 +1985,17 @@ class Connector extends EventEmitter {
1957
1985
  }
1958
1986
 
1959
1987
  /**
1960
- * Emits the ``on_data_available`` event when any Inputs within this
1988
+ * Emits the ``on_data_available`` event when any Inputs within this
1961
1989
  * :class:`Connector` object receive data.
1962
1990
  *
1963
1991
  * .. note::
1964
1992
  * This operation is asynchronous
1965
1993
  *
1966
- * This API is used internally to emit the ``on_data_available`` event when
1967
- * data is received on any of the Inputs contained within this
1994
+ * This API is used internally to emit the ``on_data_available`` event when
1995
+ * data is received on any of the Inputs contained within this
1968
1996
  * :class:`Connector` object.
1969
1997
  *
1970
- * The :class:`Connector` class extends EventEmitter, meaning that callbacks
1998
+ * The :class:`Connector` class extends EventEmitter, meaning that callbacks
1971
1999
  * can be registered for specific events using the following syntax:
1972
2000
  *
1973
2001
  * .. code-block:: javascript
@@ -1979,9 +2007,9 @@ class Connector extends EventEmitter {
1979
2007
  * // ...
1980
2008
  * connector.off('on_data_available', myCallback)
1981
2009
  *
1982
- * Once the ``on_data_available`` event has fired, either :meth:`Input.read`
1983
- * or :meth:`Input.take` should be called on the :class:`Input` that has
1984
- * new data. This will prevent ``on_data_available`` from being fired more
2010
+ * Once the ``on_data_available`` event has fired, either :meth:`Input.read`
2011
+ * or :meth:`Input.take` should be called on the :class:`Input` that has
2012
+ * new data. This will prevent ``on_data_available`` from being fired more
1985
2013
  * than once for the same data.
1986
2014
  *
1987
2015
  * @private
@@ -2067,6 +2095,38 @@ class Connector extends EventEmitter {
2067
2095
  static setMaxObjectsPerThread (value) {
2068
2096
  _checkRetcode(connectorBinding.api.RTI_Connector_set_max_objects_per_thread(value))
2069
2097
  }
2098
+
2099
+ /**
2100
+ * Returns the version of Connector.
2101
+ *
2102
+ * This static method provides the build IDs of the native libraries being used
2103
+ * by Connector, as well as the version of the Connector API.
2104
+ *
2105
+ * .. note::
2106
+ * This is a static method. It can be called before creating a
2107
+ * :class:`Connector` instance.
2108
+ *
2109
+ * @returns {string} A string containing information about the version of Connector.
2110
+ */
2111
+ static getVersion () {
2112
+ // Obtain version of Connector from package.json
2113
+ const versionString = require('./package.json').version
2114
+ // Parse numbers out of string
2115
+ const versionNumbers = versionString.split('.')
2116
+ // Now get the build IDs of the native libraries
2117
+ const nativeConnectorVersion = ref.alloc('char *')
2118
+ const nativeCoreCVersion = ref.alloc('char *')
2119
+ _checkRetcode(connectorBinding.api.RTI_Connector_get_build_versions(
2120
+ nativeCoreCVersion,
2121
+ nativeConnectorVersion))
2122
+
2123
+ // Now create the string containing all of the above information
2124
+ let versionStr = 'RTI Connector for JavaScript, version ' +
2125
+ versionNumbers[0] + '.' + versionNumbers[1] + '.' + versionNumbers[2] + '\n'
2126
+ versionStr += ref.readCString(nativeCoreCVersion.deref()) + '\n'
2127
+ versionStr += ref.readCString(nativeConnectorVersion.deref())
2128
+ return versionStr
2129
+ }
2070
2130
  }
2071
2131
 
2072
2132
  // Export the API