vrpc 3.0.0-alpha.3 → 3.0.3
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/CHANGELOG.md +53 -0
- package/LICENSE +1 -1
- package/README.md +8 -9
- package/browser/vrpc.js +1 -1
- package/package.json +8 -5
- package/vrpc/VrpcAdapter.js +209 -171
- package/vrpc/VrpcAgent.js +32 -27
- package/vrpc/VrpcClient.js +273 -119
- package/vrpc/VrpcNative.js +25 -2
- package/vrpc/adapter.hpp +4 -2
- package/vrpc/addon.cpp +1 -1
- package/vrpc/vrpc-agent-js +1 -1
package/vrpc/VrpcNative.js
CHANGED
|
@@ -16,7 +16,7 @@ Author: Dr. Burkhard C. Heisen (https://github.com/heisenware/vrpc)
|
|
|
16
16
|
|
|
17
17
|
|
|
18
18
|
Licensed under the MIT License <http://opensource.org/licenses/MIT>.
|
|
19
|
-
Copyright (c) 2018 -
|
|
19
|
+
Copyright (c) 2018 - 2022 Dr. Burkhard C. Heisen <burkhard.heisen@heisenware.com>.
|
|
20
20
|
|
|
21
21
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
22
22
|
of this software and associated documentation files (the "Software"), to deal
|
|
@@ -41,7 +41,7 @@ const EventEmitter = require('events')
|
|
|
41
41
|
const { nanoid } = require('nanoid')
|
|
42
42
|
|
|
43
43
|
/**
|
|
44
|
-
* Client capable of creating proxy
|
|
44
|
+
* Client capable of creating proxy classes and objects to locally call
|
|
45
45
|
* functions as provided through native addons.
|
|
46
46
|
*/
|
|
47
47
|
class VrpcNative {
|
|
@@ -64,6 +64,15 @@ class VrpcNative {
|
|
|
64
64
|
})
|
|
65
65
|
}
|
|
66
66
|
|
|
67
|
+
/**
|
|
68
|
+
* Provides a proxy class to an existing one in the native addon
|
|
69
|
+
*
|
|
70
|
+
* You can use the returned class in the usual way. Static function calls
|
|
71
|
+
* are forwarded to the native addon, as are any instantiations and member
|
|
72
|
+
* function calls.
|
|
73
|
+
* @param {String} className The name of the class
|
|
74
|
+
* @returns Proxy Class
|
|
75
|
+
*/
|
|
67
76
|
getClass (className) {
|
|
68
77
|
if (!this.getAvailableClasses().includes(className)) {
|
|
69
78
|
throw new Error(`Native addon does not provide class: ${className}`)
|
|
@@ -226,6 +235,11 @@ class VrpcNative {
|
|
|
226
235
|
return Klass
|
|
227
236
|
}
|
|
228
237
|
|
|
238
|
+
/**
|
|
239
|
+
* Deletes a proxy object and its underlying instance
|
|
240
|
+
* @param {Object} proxy A proxy object
|
|
241
|
+
* @returns True in case of success, false otherwise
|
|
242
|
+
*/
|
|
229
243
|
delete (proxy) {
|
|
230
244
|
if (!typeof proxy === 'object' || !proxy.vrpcProxyId) {
|
|
231
245
|
throw new Error('Provided argument seems not to be a VRPC proxy')
|
|
@@ -238,6 +252,15 @@ class VrpcNative {
|
|
|
238
252
|
return JSON.parse(this._adapter.call(JSON.stringify(json))).r
|
|
239
253
|
}
|
|
240
254
|
|
|
255
|
+
/**
|
|
256
|
+
* Secondary option to call a static function (when creation of a proxy class
|
|
257
|
+
* seems to be too much overhead)
|
|
258
|
+
*
|
|
259
|
+
* @param {String} className The class on which the static function should be called
|
|
260
|
+
* @param {String} functionName Name of the static function
|
|
261
|
+
* @param {...any} args The function arguments
|
|
262
|
+
* @returns The output of the underlying static function
|
|
263
|
+
*/
|
|
241
264
|
callStatic (className, functionName, ...args) {
|
|
242
265
|
if (functionName === 'vrpcOff') {
|
|
243
266
|
const id = `__f__${className}-vrpcOn:${args[0]}`
|
package/vrpc/adapter.hpp
CHANGED
|
@@ -12,11 +12,11 @@ __\/\\\_______\/\\\__/\\\///////\\\___\/\\\/////////\\\____/\\\////////__
|
|
|
12
12
|
|
|
13
13
|
Non-intrusively binds any C++ code and provides access in form of asynchronous
|
|
14
14
|
remote procedural callbacks (RPC).
|
|
15
|
-
Author: Dr. Burkhard C. Heisen (https://github.com/
|
|
15
|
+
Author: Dr. Burkhard C. Heisen (https://github.com/heisenware/vrpc-hpp)
|
|
16
16
|
|
|
17
17
|
|
|
18
18
|
Licensed under the MIT License <http://opensource.org/licenses/MIT>.
|
|
19
|
-
Copyright (c) 2018 -
|
|
19
|
+
Copyright (c) 2018 - 2022 Dr. Burkhard C. Heisen
|
|
20
20
|
<burkhard.heisen@heisenware.com>.
|
|
21
21
|
|
|
22
22
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
@@ -373,6 +373,7 @@ template <std::size_t I = 0, typename... Args>
|
|
|
373
373
|
I<sizeof...(Args), void>::type get_signature(std::string& signature,
|
|
374
374
|
const std::tuple<Args...>& t) {
|
|
375
375
|
json j = {{"t", std::get<I>(t)}};
|
|
376
|
+
if (!signature.empty()) signature += ":";
|
|
376
377
|
signature += j["t"].type_name();
|
|
377
378
|
return get_signature<I + 1, Args...>(signature, t);
|
|
378
379
|
}
|
|
@@ -389,6 +390,7 @@ inline std::string get_signature() {
|
|
|
389
390
|
inline std::string get_signature(const json& json) {
|
|
390
391
|
std::string signature;
|
|
391
392
|
for (const auto& it : json) {
|
|
393
|
+
if (!signature.empty()) signature += ":";
|
|
392
394
|
signature += it.type_name();
|
|
393
395
|
}
|
|
394
396
|
return signature.empty() ? signature : "-" + signature;
|
package/vrpc/addon.cpp
CHANGED
|
@@ -15,7 +15,7 @@ Author: Dr. Burkhard C. Heisen (https://github.com/heisenware/vrpc)
|
|
|
15
15
|
|
|
16
16
|
|
|
17
17
|
Licensed under the MIT License <http://opensource.org/licenses/MIT>.
|
|
18
|
-
Copyright (c) 2018 -
|
|
18
|
+
Copyright (c) 2018 - 2022 Dr. Burkhard C. Heisen
|
|
19
19
|
<burkhard.heisen@heisenware.com>.
|
|
20
20
|
|
|
21
21
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|