@aj-shadow/z-abs-corelayer-cs 0.0.0-aj-beta.221
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/.gitattributes +26 -0
- package/LICENSE.txt +96 -0
- package/README.md +5 -0
- package/npm-shrinkwrap.json +13 -0
- package/package.json +10 -0
- package/project/clientServer/_build/Bundle-CoreLayer-cs.bld +25 -0
- package/project/clientServer/_build/Client-CoreLayer-cs.bld +10 -0
- package/project/clientServer/_build/Server-CoreLayer-cs.bld +12 -0
- package/project/clientServer/_build/z-abs-corelayer-cs.prj +28 -0
- package/project/clientServer/cache/cache-array.js +38 -0
- package/project/clientServer/cache/cache-map.js +26 -0
- package/project/clientServer/cache/cache-set.js +24 -0
- package/project/clientServer/communication/action-request.js +34 -0
- package/project/clientServer/communication/action-response-error.js +18 -0
- package/project/clientServer/communication/action-response-success.js +18 -0
- package/project/clientServer/communication/app-protocol/app-deserializer.js +74 -0
- package/project/clientServer/communication/app-protocol/app-serializer.js +55 -0
- package/project/clientServer/communication/cache/text-cache.js +77 -0
- package/project/clientServer/communication/core-protocol/core-message.js +22 -0
- package/project/clientServer/communication/core-protocol/core-protocol-const.js +21 -0
- package/project/clientServer/communication/core-protocol/deserializer-message-persistent-init-request.js +12 -0
- package/project/clientServer/communication/core-protocol/deserializer-message-persistent-init-response.js +12 -0
- package/project/clientServer/communication/core-protocol/deserializer-message-request.js +45 -0
- package/project/clientServer/communication/core-protocol/deserializer-message-response.js +63 -0
- package/project/clientServer/communication/core-protocol/deserializer-message-service-init-request.js +24 -0
- package/project/clientServer/communication/core-protocol/deserializer-message-service-init-response.js +16 -0
- package/project/clientServer/communication/core-protocol/deserializer.js +349 -0
- package/project/clientServer/communication/core-protocol/encoder-const.js +21 -0
- package/project/clientServer/communication/core-protocol/encoder-giud.js +24 -0
- package/project/clientServer/communication/core-protocol/envelope.js +39 -0
- package/project/clientServer/communication/core-protocol/serializer-message-persistent-init-request.js +33 -0
- package/project/clientServer/communication/core-protocol/serializer-message-persistent-init-response.js +12 -0
- package/project/clientServer/communication/core-protocol/serializer-message-request.js +84 -0
- package/project/clientServer/communication/core-protocol/serializer-message-response.js +90 -0
- package/project/clientServer/communication/core-protocol/serializer-message-service-init-request.js +35 -0
- package/project/clientServer/communication/core-protocol/serializer-message-service-init-response.js +29 -0
- package/project/clientServer/communication/core-protocol/serializer.js +188 -0
- package/project/clientServer/communication/response-data.js +16 -0
- package/project/clientServer/communication/service-action.js +29 -0
- package/project/clientServer/debug-dashboard/garbage-collection.js +27 -0
- package/project/clientServer/debug-dashboard/log.js +444 -0
- package/project/clientServer/debug-dashboard/memory.js +73 -0
- package/project/clientServer/factory/factory-function.js +24 -0
- package/project/clientServer/factory/factory-new.js +24 -0
- package/project/clientServer/guid-generator.js +36 -0
- package/project/clientServer/memory/memory-cache-array.js +64 -0
- package/project/clientServer/memory/memory-cache-map.js +43 -0
- package/project/clientServer/memory/memory-cache-object.js +44 -0
- package/project/clientServer/memory/memory-cache-set.js +26 -0
- package/project/clientServer/memory/memory-pool.js +49 -0
- package/project/clientServer/project.js +460 -0
- package/project/clientServer/synchronization/mutex-local-callback.js +50 -0
- package/project/clientServer/time/high-resolution-date.js +24 -0
- package/project/clientServer/time/high-resolution-duration.js +41 -0
- package/project/z-abs-corelayer-cs.tree +62 -0
package/.gitattributes
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
|
|
2
|
+
# Set the default behavior, in case people don't have core.autocrlf set.
|
|
3
|
+
* text=auto
|
|
4
|
+
|
|
5
|
+
# Explicitly declare text files you want to always be normalized and converted
|
|
6
|
+
# to native line endings on checkout.
|
|
7
|
+
*.json text
|
|
8
|
+
*.js text
|
|
9
|
+
*.jsx text
|
|
10
|
+
*.txt text
|
|
11
|
+
*.md text
|
|
12
|
+
*.bld text
|
|
13
|
+
*.tsk text
|
|
14
|
+
*.css text
|
|
15
|
+
*.html text
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
# Declare files that will always have CRLF line endings on checkout.
|
|
19
|
+
#*.sln text eol=crlf
|
|
20
|
+
|
|
21
|
+
# Declare files that will always have LF line endings on checkout.
|
|
22
|
+
#*.txt text eol=lf
|
|
23
|
+
|
|
24
|
+
# Denote all files that are truly binary and should not be modified.
|
|
25
|
+
*.png binary
|
|
26
|
+
*.jpg binary
|
package/LICENSE.txt
ADDED
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
|
|
2
|
+
LICENSE AGREEMENT
|
|
3
|
+
|
|
4
|
+
Effective: 1st of November 2020
|
|
5
|
+
This License Agreement is between Licensee and Hagnell Konsulting AB (a company incorporated in Sweden with
|
|
6
|
+
company registration number: 559476-0570) (“Hagnell Konsulting”) and governs the use by Licensee of ActorJs
|
|
7
|
+
(as defined below).
|
|
8
|
+
By installing the Software (as defined below), Licensee agrees to be bound by the terms of this License Agreement.
|
|
9
|
+
|
|
10
|
+
DEFENITIONS
|
|
11
|
+
ActorJs The test tool developed by Hagnell Konsulting, utilizing the Patent and the Software.
|
|
12
|
+
Derivative Works Any work, whether in source or object code, which is based on the Software and which
|
|
13
|
+
does not constitute a new and independent work pursuant to paragraph 2 of article 4 of
|
|
14
|
+
the Swedish Act (1960:729) on Copyright in Literary and Artistic Works.
|
|
15
|
+
Documentation The manuals and instruction materials furnished by Hagnell Konsulting in connection
|
|
16
|
+
with ActorJs.
|
|
17
|
+
Licensee The physical or legal person to which the License hereunder has been granted by
|
|
18
|
+
Hagnell Konsulting.
|
|
19
|
+
Patent The patent application for a system and method for testing of systems under test, patent
|
|
20
|
+
application number:19218798.7 (European Patent Office).
|
|
21
|
+
Software The software developed and owned by Hagnell Konsulting, identified as ActorJs.
|
|
22
|
+
|
|
23
|
+
§ 1 - LICENSE
|
|
24
|
+
Licensee is hereby granted a limited, non-exclusive and non-transferable license to use ActorJs (including any
|
|
25
|
+
Derivative Works created by Licensee hereunder) (the “License”). The License is granted subject to the terms and
|
|
26
|
+
conditions set forth below.
|
|
27
|
+
The Software is licensed to Licensee on an open source basis. The License includes the right to create Derivative
|
|
28
|
+
Works pursuant to sub-clause 3 below.
|
|
29
|
+
ActorJs may be used only by Licensee himself/herself/itself, or (if, for instance, Licensee is a company), by the
|
|
30
|
+
employees and consultants of Licensee.
|
|
31
|
+
The License does not include any updates to the Software, or any support services. Notwithstanding the foregoing,
|
|
32
|
+
should Hagnell Konsulting furnish any updates to Licensee, such updates shall be subject to the License granted hereunder.
|
|
33
|
+
As regards the Documentation provided by Hagnell Konsulting, Licensee may use this Documentation for the purpose of
|
|
34
|
+
the License hereunder (only). Licensee shall not be entitled to distribute copies of the Documentation, or electronically
|
|
35
|
+
communicate the Documentation, to recipients who are not employees or consultants of Licensee.
|
|
36
|
+
|
|
37
|
+
§ 2 - LICENSE RESTRICTIONS
|
|
38
|
+
Licensee may not:
|
|
39
|
+
i) Rent, lease, lend, sell, distribute, transfer or otherwise make available ActorJs (and/or a Derivative Work)
|
|
40
|
+
(whether for value or otherwise) to third parties without Hagnell Konsulting´s written approval. Any such approval
|
|
41
|
+
will be subject to the third party acknowledging in writing (vis-à-vis Hagnell Konsulting) that its use of ActorJs
|
|
42
|
+
(and/or the Derivative Work) shall be subject to the terms and conditions of this Agreement.
|
|
43
|
+
|
|
44
|
+
ii) Distribute copies of the Software (and/or a Derivate Work), or electronically communicate the Software
|
|
45
|
+
(and/or a Derivative Work), to recipients who are not employees or consultants of Licensee.
|
|
46
|
+
|
|
47
|
+
§ 3 – DERITATIVE WORKS
|
|
48
|
+
Should Licensee, or (if applicable) any of its employees or consultants, create a Derivative Work, Licensee shall
|
|
49
|
+
inform Hagnell Konsulting thereof in writing (an e-mail shall be sufficient). Licensee may use the Derivative Work to the
|
|
50
|
+
same extent as it may use the Software hereunder, but Hagnell Konsulting shall be the sole and exclusive owner of any
|
|
51
|
+
and all rights in the Derivative Work, including the copyright. At the request of Hagnell Konsulting, Licensee and
|
|
52
|
+
Hagnell Konsulting shall formalize the rights transfer in a written contract, which shall, inter alia, confirm that all rights
|
|
53
|
+
in the Derivative Work have been irrevocably transferred to Hagnell Konsulting, that Hagnell Konsulting is be entitled to
|
|
54
|
+
exploit the Derivative Work without limitation in time or any other kind of limitation, that Hagnell Konsulting may transfer
|
|
55
|
+
its rights to the Derivative Work to third parties and that the rights transfer from Licensee to Hagnell Konsulting shall be
|
|
56
|
+
free of charge.
|
|
57
|
+
|
|
58
|
+
§ 4 – IMPROVEMENTS TO THE PATENT
|
|
59
|
+
Any improvement to the Patent, whether patentable or not, which Licensee, or (if applicable) any of its employees or
|
|
60
|
+
consultants, may discover, create or develop or otherwise have at its disposal, directly or indirectly, without restraints
|
|
61
|
+
as to the use thereof (“Improvements”), shall be disclosed promptly to Hagnell Konsulting and Hagnell Konsulting shall
|
|
62
|
+
have the exclusive right of perpetual duration to use the Improvements as well as to grant the use thereof to other licensees
|
|
63
|
+
in the whole world without compensation to Licensee, except that Licensee shall during the life of this Agreement have
|
|
64
|
+
the non-exclusive right to use such Improvements including corresponding patents, if any, in accordance with the
|
|
65
|
+
provisions of this Agreement. If Licensee decides not to apply for a patent relating to an Improvement made by
|
|
66
|
+
Licensee or if Licensee no longer wishes to maintain such a patent or patent application then Hagnell Konsulting may in its
|
|
67
|
+
sole discretion and at its own expense apply for such a patent or maintain such a patent or patent application (as the
|
|
68
|
+
case may be).
|
|
69
|
+
|
|
70
|
+
§ 5 - COPYRIGHT AND INTELLECTUAL PROPERTY RIGHTS
|
|
71
|
+
The Software, the Patent and the Documentation are protected by copyright and patent laws and international
|
|
72
|
+
copyright and patent treaties, as well other intellectual property laws and treaties. Any such intellectual property
|
|
73
|
+
rights are owned and especially reserved by Hagnell Konsulting, without limitation. For the avoidance of doubt, no
|
|
74
|
+
ownership rights are transferred to Licensee hereunder.
|
|
75
|
+
“ActorJs” is a registered trademark of Hagnell Konsulting. This Agreement does not include a license to use the
|
|
76
|
+
trademark “ActorJs”.
|
|
77
|
+
|
|
78
|
+
§ 6 - LIMITITATION ON LIABILITY
|
|
79
|
+
ActorJs is licensed to Licensee “as is”. Hagnell Konsulting gives no guarantees as regards the use, functionality
|
|
80
|
+
or performance of ActorJs and assumes no liability (whatsoever) as regards any defaults in ActorJs or any possible
|
|
81
|
+
infringements on third party statutory or contractual rights. Hagnell Konsulting expressly disclaims any and all warranties
|
|
82
|
+
not expressly given in this Agreement, including any implied warranties of merchantability, satisfactory quality, fitness
|
|
83
|
+
for a particular purpose, title and non-infringement. Thus, the entire risk arising out of any use of ActorJs hereunder
|
|
84
|
+
remains with Licensee.
|
|
85
|
+
The limitation of liability hereunder shall be to the maximum extent permitted by applicable law. Under no
|
|
86
|
+
circumstances shall Hagnell Konsulting be liable for any cost of substitute products or services, for any indirect losses or
|
|
87
|
+
for any consequential damages (including any loss of profits, interruptions or loss of business information).
|
|
88
|
+
|
|
89
|
+
§ 7 - MISCELLANEOUS
|
|
90
|
+
Licensee may not, either wholly or partly, assign or pledge its rights or obligations under this Agreement to any third
|
|
91
|
+
party without the prior written consent of Hagnell Konsulting.
|
|
92
|
+
|
|
93
|
+
§ 8 - DISPUTES
|
|
94
|
+
This agreement shall be governed by Swedish law. Any dispute, controversy or claim arising out of or in connection
|
|
95
|
+
with this contract, or the breach, termination or invalidity thereof, shall be settled by the general courts of Sweden,
|
|
96
|
+
with the district court of Stockholm in the first instance.
|
package/README.md
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@aj-shadow/z-abs-corelayer-cs",
|
|
3
|
+
"version": "0.0.0-aj-beta.221",
|
|
4
|
+
"lockfileVersion": 3,
|
|
5
|
+
"requires": true,
|
|
6
|
+
"packages": {
|
|
7
|
+
"": {
|
|
8
|
+
"name": "@aj-shadow/z-abs-corelayer-cs",
|
|
9
|
+
"version": "0.0.0-aj-beta.221",
|
|
10
|
+
"license": "SEE LICENSE IN LICENSE.txt"
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@aj-shadow/z-abs-corelayer-cs",
|
|
3
|
+
"version": "0.0.0-aj-beta.221",
|
|
4
|
+
"release-step": "delivery",
|
|
5
|
+
"description": "Library used by @actorjs/actorjs",
|
|
6
|
+
"author": "ActorJs",
|
|
7
|
+
"license": "SEE LICENSE IN LICENSE.txt",
|
|
8
|
+
"repository": "https://gitlab.com/actorjs-shadow-delivery-public/z-abs-corelayer-cs.git",
|
|
9
|
+
"dependencies": {}
|
|
10
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
{
|
|
2
|
+
"layer": "Core",
|
|
3
|
+
"part": "cs",
|
|
4
|
+
"source": {
|
|
5
|
+
"path": "./build/z-abs-corelayer-cs/clientServer",
|
|
6
|
+
"filters": ["js"]
|
|
7
|
+
},
|
|
8
|
+
"dest": "./dist/scripts",
|
|
9
|
+
"_bundle": true,
|
|
10
|
+
"ignores": [
|
|
11
|
+
"cli-color",
|
|
12
|
+
"path"
|
|
13
|
+
],
|
|
14
|
+
"externals": [
|
|
15
|
+
"os",
|
|
16
|
+
"_process"
|
|
17
|
+
],
|
|
18
|
+
"externalGlobs": null,
|
|
19
|
+
"exports": null,
|
|
20
|
+
"exportSource": true,
|
|
21
|
+
"dependencyNames": [
|
|
22
|
+
"Client:CoreLayer/cs",
|
|
23
|
+
"Client:3ppLayer/Nodejs-client"
|
|
24
|
+
]
|
|
25
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
{
|
|
2
|
+
"builds": [
|
|
3
|
+
{
|
|
4
|
+
"name": "Server:CoreLayer/cs",
|
|
5
|
+
"type": "server",
|
|
6
|
+
"fileName": "Server-CoreLayer-cs",
|
|
7
|
+
"requireName": "build-server-js",
|
|
8
|
+
"repo": "z-abs-corelayer-cs",
|
|
9
|
+
"repoPath": "."
|
|
10
|
+
},
|
|
11
|
+
{
|
|
12
|
+
"name": "Client:CoreLayer/cs",
|
|
13
|
+
"type": "client",
|
|
14
|
+
"fileName": "Client-CoreLayer-cs",
|
|
15
|
+
"requireName": "build-client-js",
|
|
16
|
+
"repo": "z-abs-corelayer-cs",
|
|
17
|
+
"repoPath": "."
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
"name": "Bundle:CoreLayer/cs",
|
|
21
|
+
"type": "client",
|
|
22
|
+
"fileName": "Bundle-CoreLayer-cs",
|
|
23
|
+
"requireName": "build-client-bundle",
|
|
24
|
+
"repo": null,
|
|
25
|
+
"repoPath": "."
|
|
26
|
+
}
|
|
27
|
+
]
|
|
28
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
class CacheArray {
|
|
6
|
+
constructor() {
|
|
7
|
+
this.cacheArray = [];
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
get() {
|
|
11
|
+
if(0 !== this.cacheArray.length) {
|
|
12
|
+
return this.cacheArray.pop();
|
|
13
|
+
}
|
|
14
|
+
else {
|
|
15
|
+
return new Array(4);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
put(array) {
|
|
20
|
+
array.length = 4;
|
|
21
|
+
this.cacheArray.push(array);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
setValue(array, index, value) {
|
|
25
|
+
if(index < array.length) {
|
|
26
|
+
array[index] = value;
|
|
27
|
+
}
|
|
28
|
+
else {
|
|
29
|
+
while(array.length <= index) {
|
|
30
|
+
array.push(null);
|
|
31
|
+
}
|
|
32
|
+
array.push(value);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
module.exports = CacheArray;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
class CacheMap {
|
|
6
|
+
constructor() {
|
|
7
|
+
this.cacheMap = [];
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
get() {
|
|
11
|
+
if(0 !== this.cacheMap.length) {
|
|
12
|
+
return this.cacheMap.pop();
|
|
13
|
+
}
|
|
14
|
+
else {
|
|
15
|
+
return new Map();
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
put(map) {
|
|
20
|
+
map.clear();
|
|
21
|
+
this.cacheMap.push(map);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
module.exports = CacheMap;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
class CacheSet {
|
|
6
|
+
static cache = [];
|
|
7
|
+
|
|
8
|
+
static get() {
|
|
9
|
+
if(0 !== CacheSet.cache.length) {
|
|
10
|
+
return CacheSet.cache.pop();
|
|
11
|
+
}
|
|
12
|
+
else {
|
|
13
|
+
return new Set();
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
static put(set) {
|
|
18
|
+
set.clear();
|
|
19
|
+
CacheSet.cache.push(set);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
module.exports = CacheSet;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
const CoreProtocolConst = require('./core-protocol/core-protocol-const');
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
class ActionRequest {
|
|
8
|
+
constructor(requests = []) {
|
|
9
|
+
this.msgId = CoreProtocolConst.REQUEST;
|
|
10
|
+
this.id = '';
|
|
11
|
+
this.requests = requests;
|
|
12
|
+
this.isServiceAction = false;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
setIds(requestId, sessionId) {
|
|
16
|
+
this.id = requestId;
|
|
17
|
+
this.requests.forEach((request) => {
|
|
18
|
+
request.sessionId = sessionId;
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
add(name, index, ...params) {
|
|
23
|
+
this.requests.push({
|
|
24
|
+
name: name,
|
|
25
|
+
index: index,
|
|
26
|
+
sessionId: undefined,
|
|
27
|
+
params: [...params]
|
|
28
|
+
});
|
|
29
|
+
return this;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
module.exports = ActionRequest;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
class ActionResponseError {
|
|
6
|
+
constructor(name, index, msg) {
|
|
7
|
+
this.name = name;
|
|
8
|
+
this.index = index;
|
|
9
|
+
this.isServiceAction = false;
|
|
10
|
+
this.result = {
|
|
11
|
+
code: 'error',
|
|
12
|
+
msg: msg
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
module.exports = ActionResponseError;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
class ActionResponseSuccess {
|
|
6
|
+
constructor(name, index, data) {
|
|
7
|
+
this.name = name;
|
|
8
|
+
this.index = index;
|
|
9
|
+
this.data = data;
|
|
10
|
+
this.isServiceAction = false;
|
|
11
|
+
this.result = {
|
|
12
|
+
code: 'success'
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
module.exports = ActionResponseSuccess;
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
class AppDeserializer {
|
|
6
|
+
constructor(decoder, decoderCahced) {
|
|
7
|
+
this.decoder = decoder;
|
|
8
|
+
this.decoderCahced = decoderCahced;
|
|
9
|
+
this.dataDecoders = new Map();
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
do(msgId, buffer, dataBuffers, isServiceAction) {
|
|
13
|
+
return this._do(msgId, buffer, dataBuffers, isServiceAction);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
clear() {
|
|
17
|
+
this.decoder.clear();
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
_do(msgId, buffer, dataBuffers, isServiceAction) {
|
|
21
|
+
const deserializerData = this.dataDecoders.get(msgId);
|
|
22
|
+
if(!deserializerData) {
|
|
23
|
+
return null;
|
|
24
|
+
}
|
|
25
|
+
else {
|
|
26
|
+
this.decoder.add(buffer);
|
|
27
|
+
if(this.decoder.has(buffer.byteLength)) {
|
|
28
|
+
const msg = deserializerData.deserializer.do(msgId, deserializerData.onRealtimeName, this.decoder, isServiceAction);
|
|
29
|
+
if(msg) {
|
|
30
|
+
this.decoder.got();
|
|
31
|
+
return msg;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
return null;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
doMsg(msg) {
|
|
39
|
+
const deserializerData = this.dataDecoders.get(msg.msgId);
|
|
40
|
+
if(deserializerData) {
|
|
41
|
+
msg.onRealtimeName = deserializerData.onRealtimeName;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
doCachedText(cachedTextBuffer) {
|
|
46
|
+
const decoder = this.decoderCahced;
|
|
47
|
+
decoder.add(cachedTextBuffer);
|
|
48
|
+
decoder.has(cachedTextBuffer.byteLength);
|
|
49
|
+
const nbrOfCachedTexts = decoder.getUint8();
|
|
50
|
+
for(let i = 0; i < nbrOfCachedTexts; ++i) {
|
|
51
|
+
const ct = decoder.getCt();
|
|
52
|
+
const text = decoder.getString();
|
|
53
|
+
this.decoder.textCache.set(ct, text);
|
|
54
|
+
}
|
|
55
|
+
decoder.got();
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
register(id, name, deserializer) {
|
|
59
|
+
if(!this.dataDecoders.has(id)) {
|
|
60
|
+
this.dataDecoders.set(id, {
|
|
61
|
+
onRealtimeName: name ? `onRealtime${name}` : null,
|
|
62
|
+
name: deserializer ? deserializer.constructor.name : (name ? name : 'unknown'),
|
|
63
|
+
deserializer: deserializer
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
else {
|
|
67
|
+
const deserializerData = this.dataDecoders.get(id);
|
|
68
|
+
ddb.error(`App deserializer: ${deserializerData.name} have already registered the id: ${id}`);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
module.exports = AppDeserializer;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
class AppSerializer {
|
|
6
|
+
constructor() {
|
|
7
|
+
this.appSerializers = new Map();
|
|
8
|
+
this.encoder = null;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
init(encoder) {
|
|
12
|
+
this.encoder = encoder;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
do(msgId, msg, cachedTexts) {
|
|
16
|
+
const buffer = this._do(msgId, msg, cachedTexts);
|
|
17
|
+
this.encoder.clear();
|
|
18
|
+
return buffer;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
clear() {
|
|
22
|
+
this.textCache.clear();
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
_do(msgId, msg, cachedTexts) {
|
|
26
|
+
const serializerData = this.appSerializers.get(msgId);
|
|
27
|
+
if(serializerData) {
|
|
28
|
+
return serializerData.appSerializer.do(msg, cachedTexts);
|
|
29
|
+
}
|
|
30
|
+
else {
|
|
31
|
+
return null;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
_register(msgId, appSerializer) {
|
|
36
|
+
appSerializer.init(this.encoder);
|
|
37
|
+
this.appSerializers.set(msgId, {
|
|
38
|
+
name: appSerializer ? appSerializer.constructor.name : 'null',
|
|
39
|
+
appSerializer: appSerializer
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
register(msgId, appSerializer) {
|
|
44
|
+
if(!this.appSerializers.has(msgId)) {
|
|
45
|
+
this._register(msgId, appSerializer);
|
|
46
|
+
}
|
|
47
|
+
else {
|
|
48
|
+
const serializerData = this.appSerializers.get(msgId);
|
|
49
|
+
ddb.error(`App serializer: ${serializerData.name} have already registered the msgId: ${msgId}`);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
module.exports = AppSerializer;
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
class TextCache {
|
|
6
|
+
constructor(name, pid=null) {
|
|
7
|
+
this.name = name;
|
|
8
|
+
this.pid = pid;
|
|
9
|
+
this.externalId = 0;
|
|
10
|
+
this.externalText = new Map([['', 0]]);
|
|
11
|
+
this.externalNumber = [''];
|
|
12
|
+
this.internalId = 0;
|
|
13
|
+
this.internalText = new Map([['', 0]]);
|
|
14
|
+
this.internalNumber = [''];
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
getText(id) {
|
|
18
|
+
if(id >= 0) {
|
|
19
|
+
return this.externalNumber[id];
|
|
20
|
+
}
|
|
21
|
+
else {
|
|
22
|
+
return this.internalNumber[id];
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
set(id, text) {
|
|
27
|
+
this.externalText.set(text, id);
|
|
28
|
+
this.externalNumber.push(text);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
setExternal(text, cachedTexts) {
|
|
32
|
+
if(this.externalText.has(text)) {
|
|
33
|
+
const id = this.externalText.get(text);
|
|
34
|
+
return id;
|
|
35
|
+
}
|
|
36
|
+
else {
|
|
37
|
+
const id = ++this.externalId;
|
|
38
|
+
this.externalText.set(text, id);
|
|
39
|
+
this.externalNumber.push(text);
|
|
40
|
+
++cachedTexts.nbr;
|
|
41
|
+
cachedTexts.texts.push({
|
|
42
|
+
id: id,
|
|
43
|
+
text: text
|
|
44
|
+
});
|
|
45
|
+
return id;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
setInternal(text) {
|
|
50
|
+
if(this.externalText.has(text)) {
|
|
51
|
+
const id = this.externalText.get(text);
|
|
52
|
+
return id;
|
|
53
|
+
}
|
|
54
|
+
else if(this.internalText.has(text)) {
|
|
55
|
+
const id = this.internalText.get(text);
|
|
56
|
+
return id;
|
|
57
|
+
}
|
|
58
|
+
else {
|
|
59
|
+
const id = --this.internalId;
|
|
60
|
+
this.internalText.set(text, id);
|
|
61
|
+
this.internalNumber.push(text);
|
|
62
|
+
return id;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
clear() {
|
|
67
|
+
this.externalId = 0;
|
|
68
|
+
this.externalText.clear();
|
|
69
|
+
this.externalNumber = [];
|
|
70
|
+
this.internalId = 0;
|
|
71
|
+
this.internalText.clear();
|
|
72
|
+
this.internalNumber = [];
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
module.exports = TextCache;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
class CoreMessage {
|
|
6
|
+
constructor(msgId, hasEnvelope, isBinary, hasBuffers, hasTextCache, isServiceAction, envelope, msg, bin, cachedTextBuffer, dataBuffers) {
|
|
7
|
+
this.msgId = msgId;
|
|
8
|
+
this.hasEnvelope = hasEnvelope;
|
|
9
|
+
this.isBinary = isBinary;
|
|
10
|
+
this.hasBuffers = hasBuffers;
|
|
11
|
+
this.hasTextCache = hasTextCache;
|
|
12
|
+
this.isServiceAction = isServiceAction;
|
|
13
|
+
this.envelope = envelope;
|
|
14
|
+
this.msg = msg;
|
|
15
|
+
this.bin = bin;
|
|
16
|
+
this.cachedTextBuffer = cachedTextBuffer;
|
|
17
|
+
this.dataBuffers = dataBuffers;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
module.exports = CoreMessage;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
class CoreProtocolConst {
|
|
6
|
+
static REQUEST = 1;
|
|
7
|
+
static RESPONSE = 2;
|
|
8
|
+
static WORKER_INIT_REQUEST = 3;
|
|
9
|
+
static WORKER_INIT_RESPONSE = 4;
|
|
10
|
+
static PERSISTENT_INIT_REQUEST = 5;
|
|
11
|
+
static PERSISTENT_INIT_RESPONSE = 6;
|
|
12
|
+
static PERSISTENT_PUBLISH = 7;
|
|
13
|
+
static SERVICE_INIT_REQUEST = 8;
|
|
14
|
+
static SERVICE_INIT_RESPONSE = 9;
|
|
15
|
+
static SERVICE_OFFER_ON = 10;
|
|
16
|
+
static SERVICE_OFFER_OFF = 11;
|
|
17
|
+
static APP = 999;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
module.exports = CoreProtocolConst;
|