@@ -138,7 +138,8 @@ class _ConnectorBinding {
138138 RTI_Connector_set_max_objects_per_thread : [ 'int' , [ 'int' ] ] ,
139139 RTIDDSConnector_getJSONInstance :[ 'char *' , [ 'pointer' , 'string' ] ] ,
140140 // This API is only used in the unit tests
141- RTI_Connector_create_test_scenario : [ 'int' , [ 'pointer' , 'int' , 'pointer' ] ]
141+ RTI_Connector_create_test_scenario : [ 'int' , [ 'pointer' , 'int' , 'pointer' ] ] ,
142+ RTI_Connector_get_build_versions : [ 'int' , [ ref . refType ( 'char *' ) , ref . refType ( 'char *' ) ] ]
142143 } )
143144 }
144145}
@@ -2067,6 +2068,38 @@ class Connector extends EventEmitter {
20672068 static setMaxObjectsPerThread ( value ) {
20682069 _checkRetcode ( connectorBinding . api . RTI_Connector_set_max_objects_per_thread ( value ) )
20692070 }
2071+
2072+ /**
2073+ * Returns the version of Connector.
2074+ *
2075+ * This static method provides the build IDs of the native libraries being used
2076+ * by Connector, as well as the version of the Connector API.
2077+ *
2078+ * .. note::
2079+ * This is a static method. It can be called before creating a
2080+ * :class:`Connector` instance.
2081+ *
2082+ * @returns {string } A string containing information about the version of Connector.
2083+ */
2084+ static get_version ( ) {
2085+ // Obtain version of Connector from package.json
2086+ const versionString = require ( './package.json' ) . version
2087+ // Parse numbers out of string
2088+ const versionNumbers = versionString . split ( '.' )
2089+ // Now get the build IDs of the native libraries
2090+ const nativeConnectorVersion = ref . alloc ( 'char *' )
2091+ const nativeCoreCVersion = ref . alloc ( 'char *' )
2092+ _checkRetcode ( connectorBinding . api . RTI_Connector_get_build_versions (
2093+ nativeCoreCVersion ,
2094+ nativeConnectorVersion ) )
2095+
2096+ // Now create the string containing all of the above information
2097+ let versionStr = "RTI Connector for JavaScript, version "
2098+ + versionNumbers [ 0 ] + "." + versionNumbers [ 1 ] + "." + versionNumbers [ 2 ] + "\n"
2099+ versionStr += ref . readCString ( nativeCoreCVersion . deref ( ) ) + "\n"
2100+ versionStr += ref . readCString ( nativeConnectorVersion . deref ( ) )
2101+ return versionStr
2102+ }
20702103}
20712104
20722105// Export the API
0 commit comments