@aj-shadow/z-abs-funclayer-engine-server 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/server/_build/Server-FuncLayer-Engine-server.bld +12 -0
- package/project/server/_build/z-abs-funclayer-engine-server.prj +12 -0
- package/project/server/address/address-calculator.js +377 -0
- package/project/server/address/address-data.js +364 -0
- package/project/server/address/address-manager.js +251 -0
- package/project/server/address/address.js +176 -0
- package/project/server/address/addresses.js +122 -0
- package/project/server/address/dns-url-cache.js +130 -0
- package/project/server/address/interfaces.js +100 -0
- package/project/server/address/local-dns.js +35 -0
- package/project/server/address/login-report.js +56 -0
- package/project/server/address/networks.js +598 -0
- package/project/server/address/real-networks.js +102 -0
- package/project/server/address/subnet.js +60 -0
- package/project/server/communication/messages/messages-s-to-c/message-execution-started.js +17 -0
- package/project/server/communication/messages/messages-s-to-c/message-execution-stopped.js +14 -0
- package/project/server/communication/messages/messages-s-to-c/message-test-case-debug-paused.js +18 -0
- package/project/server/communication/messages/messages-s-to-c/message-test-case-log.js +25 -0
- package/project/server/communication/messages/messages-s-to-c/message-test-case-started.js +21 -0
- package/project/server/communication/messages/messages-s-to-c/message-test-case-state.js +18 -0
- package/project/server/communication/messages/messages-s-to-c/message-test-case-stopped.js +22 -0
- package/project/server/communication/messages/messages-s-to-c/message-test-stage-started.js +19 -0
- package/project/server/communication/messages/messages-s-to-c/message-test-stage-stopped.js +19 -0
- package/project/server/communication/messages/messages-s-to-c/message-test-suite-started.js +16 -0
- package/project/server/communication/messages/messages-s-to-c/message-test-suite-stopped.js +19 -0
- package/project/server/communication/messages/messages-s-to-w/message-test-case-debug-actor-index-ok.js +15 -0
- package/project/server/communication/messages/messages-w-to-s/message-test-case-debug-actor-index.js +15 -0
- package/project/server/debug/debug-step-over.js +54 -0
- package/project/server/debug/debugger.js +102 -0
- package/project/server/debug-dashboard/debug-dashboard.js +14 -0
- package/project/server/debug-dashboard/gauge-manager.js +44 -0
- package/project/server/debug-dashboard/gauge.js +37 -0
- package/project/server/engine/actor/actor-condition.js +335 -0
- package/project/server/engine/actor/actor-intercepting.js +32 -0
- package/project/server/engine/actor/actor-local.js +24 -0
- package/project/server/engine/actor/actor-mixins/asynch-mixin.js +103 -0
- package/project/server/engine/actor/actor-mixins/content-mixin.js +22 -0
- package/project/server/engine/actor/actor-mixins/logger-mixin.js +603 -0
- package/project/server/engine/actor/actor-mixins/process-mixin.js +35 -0
- package/project/server/engine/actor/actor-mixins/shared-data-mixin.js +109 -0
- package/project/server/engine/actor/actor-mixins/shared-execution-data-mixin.js +57 -0
- package/project/server/engine/actor/actor-mixins/stack-mixin-client.js +157 -0
- package/project/server/engine/actor/actor-mixins/stack-mixin-server.js +123 -0
- package/project/server/engine/actor/actor-mixins/stack-mixin.js +128 -0
- package/project/server/engine/actor/actor-mixins/test-data-mixin.js +402 -0
- package/project/server/engine/actor/actor-mixins/timer-mixin.js +44 -0
- package/project/server/engine/actor/actor-mixins/verify-mixin-base.js +668 -0
- package/project/server/engine/actor/actor-mixins/verify-mixin-mandatory.js +46 -0
- package/project/server/engine/actor/actor-mixins/verify-mixin-optional.js +44 -0
- package/project/server/engine/actor/actor-mixins/verify-mixin-value.js +71 -0
- package/project/server/engine/actor/actor-originating.js +32 -0
- package/project/server/engine/actor/actor-part-mixins/part-asynch-mixin.js +24 -0
- package/project/server/engine/actor/actor-part-mixins/part-logger-mixin.js +39 -0
- package/project/server/engine/actor/actor-part-mixins/part-shared-runtime-data-mixin.js +33 -0
- package/project/server/engine/actor/actor-part-mixins/part-timer-mixin.js +12 -0
- package/project/server/engine/actor/actor-part-mixins/part-verify-mixin-mandatory.js +15 -0
- package/project/server/engine/actor/actor-part-mixins/part-verify-mixin-optional.js +15 -0
- package/project/server/engine/actor/actor-part-mixins/part-verify-mixin-value.js +15 -0
- package/project/server/engine/actor/actor-part-post.js +37 -0
- package/project/server/engine/actor/actor-part-pre.js +37 -0
- package/project/server/engine/actor/actor-pending.js +79 -0
- package/project/server/engine/actor/actor-proxy.js +38 -0
- package/project/server/engine/actor/actor-results.js +36 -0
- package/project/server/engine/actor/actor-state-timeout.js +35 -0
- package/project/server/engine/actor/actor-sut.js +38 -0
- package/project/server/engine/actor/actor-terminating.js +32 -0
- package/project/server/engine/actor/actor.js +553 -0
- package/project/server/engine/actor-phase.js +26 -0
- package/project/server/engine/actor-state-machine-base.js +298 -0
- package/project/server/engine/actor-state-machine-data.js +383 -0
- package/project/server/engine/actor-state-machine-exec.js +137 -0
- package/project/server/engine/actor-state-machine-post.js +177 -0
- package/project/server/engine/actor-state-machine-pre.js +142 -0
- package/project/server/engine/actor-state-machine-process.js +88 -0
- package/project/server/engine/actor-state-machine-state.js +52 -0
- package/project/server/engine/actor-state-machine.js +185 -0
- package/project/server/engine/actor-state.js +35 -0
- package/project/server/engine/actor-worker.js +68 -0
- package/project/server/engine/actors-phase.js +49 -0
- package/project/server/engine/actors.js +317 -0
- package/project/server/engine/data/content-audio.js +18 -0
- package/project/server/engine/data/content-base.js +91 -0
- package/project/server/engine/data/content-binary.js +15 -0
- package/project/server/engine/data/content-cache.js +67 -0
- package/project/server/engine/data/content-data.js +254 -0
- package/project/server/engine/data/content-documents.js +18 -0
- package/project/server/engine/data/content-image.js +20 -0
- package/project/server/engine/data/content-other.js +19 -0
- package/project/server/engine/data/content-text.js +19 -0
- package/project/server/engine/data/content-undefined.js +14 -0
- package/project/server/engine/data/content-video.js +20 -0
- package/project/server/engine/data/content.js +60 -0
- package/project/server/engine/data/runtime-data-shared.js +75 -0
- package/project/server/engine/data/test-data.js +239 -0
- package/project/server/engine/execution-context-test-case.js +48 -0
- package/project/server/engine/execution-context-test-suite.js +66 -0
- package/project/server/engine/execution-context.js +93 -0
- package/project/server/engine/stage-setter.js +132 -0
- package/project/server/engine/stage.js +83 -0
- package/project/server/engine/test-case-load.js +25 -0
- package/project/server/engine/test-case-loader.js +125 -0
- package/project/server/engine/test-case-not-found.js +29 -0
- package/project/server/engine/test-case-result-type.js +42 -0
- package/project/server/engine/test-case.js +417 -0
- package/project/server/engine/test-output.js +116 -0
- package/project/server/engine/test-statistics-test-case.js +59 -0
- package/project/server/engine/test-statistics-test-suite.js +63 -0
- package/project/server/engine/test-suite.js +276 -0
- package/project/server/stack/api/base-64.js +16 -0
- package/project/server/stack/api/const-commands-decoder.js +15 -0
- package/project/server/stack/api/const-commands-encoder.js +15 -0
- package/project/server/stack/api/hmacSha1.js +14 -0
- package/project/server/stack/api/json-web-token.js +38 -0
- package/project/server/stack/api/sdp/sdp-decoder.js +70 -0
- package/project/server/stack/api/sdp/sdp-encoder.js +40 -0
- package/project/server/stack/api/sdp/sdp-media-attribute.js +13 -0
- package/project/server/stack/api/sdp/sdp-media-session.js +16 -0
- package/project/server/stack/api/sdp/sdp-message.js +17 -0
- package/project/server/stack/api/sdp/sdp-origin.js +17 -0
- package/project/server/stack/api/sdp/sdp-session-attribute.js +13 -0
- package/project/server/stack/api/sdp/sdp-timing.js +15 -0
- package/project/server/stack/api/text-protocol-header.js +35 -0
- package/project/server/stack/factory/stack-components-helpers.js +22 -0
- package/project/server/stack/factory/stack-components-template-base-actors.js +124 -0
- package/project/server/stack/factory/stack-components-template-base-test-cases.js +22 -0
- package/project/server/stack/factory/stack-components-templates-actors.js +15 -0
- package/project/server/stack/factory/stack-components-templates-test-cases.js +20 -0
- package/project/server/stack/managers/client-manager/client-manager.js +193 -0
- package/project/server/stack/managers/connection-manager/connection-data.js +82 -0
- package/project/server/stack/managers/connection-manager/connection-manager.js +177 -0
- package/project/server/stack/managers/connection-manager/connection-object.js +148 -0
- package/project/server/stack/managers/connection-manager/shared-data.js +14 -0
- package/project/server/stack/managers/manager.js +95 -0
- package/project/server/stack/managers/server-manager/server-manager.js +76 -0
- package/project/server/stack/managers/server-manager/server.js +384 -0
- package/project/server/stack/managers/shared-manager.js +117 -0
- package/project/server/stack/network/buffer-manager.js +190 -0
- package/project/server/stack/network/mc/mc-connection-client-shared.js +51 -0
- package/project/server/stack/network/mc/mc-connection-client.js +117 -0
- package/project/server/stack/network/mc/mc-connection-server-shared.js +51 -0
- package/project/server/stack/network/mc/mc-connection-server.js +58 -0
- package/project/server/stack/network/mc/mc-connection-shared.js +26 -0
- package/project/server/stack/network/mc/mc-connection.js +33 -0
- package/project/server/stack/network/mc/mc-server.js +90 -0
- package/project/server/stack/network/network-connection-shared.js +177 -0
- package/project/server/stack/network/network-connection.js +134 -0
- package/project/server/stack/network/network-helper.js +12 -0
- package/project/server/stack/network/network-server.js +36 -0
- package/project/server/stack/network/network-type.js +46 -0
- package/project/server/stack/network/tcp/tcp-connection-client-shared.js +18 -0
- package/project/server/stack/network/tcp/tcp-connection-client.js +71 -0
- package/project/server/stack/network/tcp/tcp-connection-server-shared.js +14 -0
- package/project/server/stack/network/tcp/tcp-connection-server.js +16 -0
- package/project/server/stack/network/tcp/tcp-connection-shared.js +55 -0
- package/project/server/stack/network/tcp/tcp-connection.js +167 -0
- package/project/server/stack/network/tcp/tcp-server.js +35 -0
- package/project/server/stack/network/tls/tls-connection-client-shared.js +18 -0
- package/project/server/stack/network/tls/tls-connection-client.js +76 -0
- package/project/server/stack/network/tls/tls-connection-server-shared.js +14 -0
- package/project/server/stack/network/tls/tls-connection-server.js +16 -0
- package/project/server/stack/network/tls/tls-connection-shared.js +63 -0
- package/project/server/stack/network/tls/tls-connection.js +176 -0
- package/project/server/stack/network/tls/tls-server.js +45 -0
- package/project/server/stack/network/transport.js +19 -0
- package/project/server/stack/network/udp/udp-connection-client-shared.js +47 -0
- package/project/server/stack/network/udp/udp-connection-client.js +93 -0
- package/project/server/stack/network/udp/udp-connection-server-shared.js +51 -0
- package/project/server/stack/network/udp/udp-connection-server.js +58 -0
- package/project/server/stack/network/udp/udp-connection-shared.js +26 -0
- package/project/server/stack/network/udp/udp-connection.js +33 -0
- package/project/server/stack/network/udp/udp-server.js +74 -0
- package/project/server/stack/pending/pending-const.js +22 -0
- package/project/server/stack/pending/pending-context-receive.js +18 -0
- package/project/server/stack/pending/pending-context-send.js +18 -0
- package/project/server/stack/pending/pending-context.js +18 -0
- package/project/server/stack/pending/pending-inner.js +107 -0
- package/project/server/stack/pending/pending-switch.js +146 -0
- package/project/server/stack/stacks/ascii-dictionary.js +289 -0
- package/project/server/stack/stacks/binary-log.js +88 -0
- package/project/server/stack/stacks/bit-byte.js +51 -0
- package/project/server/stack/stacks/browser-data.js +25 -0
- package/project/server/stack/stacks/cancel-object.js +16 -0
- package/project/server/stack/stacks/connection-client.js +228 -0
- package/project/server/stack/stacks/connection-instance.js +69 -0
- package/project/server/stack/stacks/connection-ip.js +374 -0
- package/project/server/stack/stacks/connection-server.js +169 -0
- package/project/server/stack/stacks/connection-web.js +113 -0
- package/project/server/stack/stacks/connection-worker-client.js +29 -0
- package/project/server/stack/stacks/connection-worker-connection.js +41 -0
- package/project/server/stack/stacks/connection-worker-server.js +29 -0
- package/project/server/stack/stacks/connection-worker.js +99 -0
- package/project/server/stack/stacks/connection.js +132 -0
- package/project/server/stack/stacks/decoder.js +83 -0
- package/project/server/stack/stacks/encoder.js +82 -0
- package/project/server/stack/stacks/ip-log.js +24 -0
- package/project/server/stack/stacks/message-selector.js +22 -0
- package/project/server/stack/stacks/msg-ip.js +18 -0
- package/project/server/stack/stacks/stack-content-cache.js +27 -0
- package/project/z-abs-funclayer-engine-server.tree +230 -0
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
const McConnectionShared = require('./mc-connection-shared');
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
class McConnectionClientShared extends McConnectionShared {
|
|
8
|
+
constructor(networkConnection, connectionName) {
|
|
9
|
+
super(networkConnection, connectionName);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
addMembership(host, interfaceHost) {
|
|
13
|
+
return this.networkConnection.addMembership(host, interfaceHost);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
connect(done) {
|
|
17
|
+
this.networkConnection.connect(done);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
closed() {
|
|
21
|
+
return this.networkConnection.closed();
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
close(done) {
|
|
25
|
+
if(0 === this.unref()) {
|
|
26
|
+
this.networkConnection.close(done);
|
|
27
|
+
}
|
|
28
|
+
else {
|
|
29
|
+
process.nextTick(done);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
sendMessage(msg) {
|
|
34
|
+
this.networkConnection.sendMessage(msg);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
getRemoteAddress() {
|
|
38
|
+
return this.networkConnection.getRemoteAddress();
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
getRemotePort() {
|
|
42
|
+
return this.networkConnection.getRemotePort();
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
getRemoteFamily() {
|
|
46
|
+
return this.networkConnection.getRemoteFamily();
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
module.exports = McConnectionClientShared;
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
const McConnection = require('./mc-connection');
|
|
5
|
+
const Dgram = require('dgram');
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class McConnectionClient extends McConnection {
|
|
9
|
+
constructor(srcAddress, dstAddress, transportProperties, connection) {
|
|
10
|
+
super(transportProperties, 'client', connection);
|
|
11
|
+
this.srcAddress = srcAddress;
|
|
12
|
+
if(0 === this.srcAddress.port) {
|
|
13
|
+
throw Error('Can not bind multicast client port to 0.');
|
|
14
|
+
}
|
|
15
|
+
this.dstAddress = dstAddress;
|
|
16
|
+
this.isOpen = false;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
addMembership(host, interfaceHost) {
|
|
20
|
+
try {
|
|
21
|
+
this.socket.setMulticastTTL(40);
|
|
22
|
+
this.socket.addSourceSpecificMembership(this.srcAddress.host, host, interfaceHost);
|
|
23
|
+
return null;
|
|
24
|
+
}
|
|
25
|
+
catch(err) {
|
|
26
|
+
return err;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
connect(done) {
|
|
31
|
+
let bindDone = done;
|
|
32
|
+
if('IPv4' === this.dstAddress.family) {
|
|
33
|
+
this.socket = Dgram.createSocket({type: 'udp4', reuseAddr: true});
|
|
34
|
+
}
|
|
35
|
+
else if('IPv6' === this.dstAddress.family) {
|
|
36
|
+
this.socket = Dgram.createSocket({type: 'udp6', reuseAddr: true});
|
|
37
|
+
}
|
|
38
|
+
else {
|
|
39
|
+
process.nextTick((done) => {
|
|
40
|
+
done(new Error(`No accepted IP family; '${dstAddress.family}'`));
|
|
41
|
+
}, done);
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
this.socket.on('error', (err) => {
|
|
45
|
+
if(bindDone) {
|
|
46
|
+
bindDone(err);
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
this.socket.bind({
|
|
50
|
+
port: this.srcAddress.port,
|
|
51
|
+
address: this.srcAddress.host,
|
|
52
|
+
reuseAddr: true
|
|
53
|
+
}, (err) => {
|
|
54
|
+
bindDone = null;
|
|
55
|
+
if(err) {
|
|
56
|
+
return done(err);
|
|
57
|
+
}
|
|
58
|
+
const error = this.addMembership(this.dstAddress.host, this.srcAddress.host);
|
|
59
|
+
if(error) {
|
|
60
|
+
return done(error);
|
|
61
|
+
}
|
|
62
|
+
this.isOpen = true;
|
|
63
|
+
done();
|
|
64
|
+
});
|
|
65
|
+
this.socket.on('message', (buffer, rinfo) => {
|
|
66
|
+
/*if(rinfo.host != this.dstAddress.host || rinfo.port != this.dstAddress.port) {
|
|
67
|
+
// TODO: addlog error here.
|
|
68
|
+
return;
|
|
69
|
+
}*/
|
|
70
|
+
this.onBuffer(buffer);
|
|
71
|
+
});
|
|
72
|
+
this.socket.on('close', () => {
|
|
73
|
+
this.isOpen = false;
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
closed() {
|
|
78
|
+
return !this.isOpen;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
close(done) {
|
|
82
|
+
if(null !== this.socket) {
|
|
83
|
+
this.socket.close((err) => {
|
|
84
|
+
// TODO: Log
|
|
85
|
+
done(err);
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
else {
|
|
89
|
+
process.nextTick(done);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
sendMessage(msg) {
|
|
94
|
+
this.socket.send(msg);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
getRemoteAddress() {
|
|
98
|
+
if(null !== this.socket) {
|
|
99
|
+
return this.dstAddress.host;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
getRemotePort() {
|
|
104
|
+
if(null !== this.socket) {
|
|
105
|
+
return this.dstAddress.port;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
getRemoteFamily() {
|
|
110
|
+
if(null !== this.socket) {
|
|
111
|
+
return this.dstAddress.family;;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
|
|
117
|
+
module.exports = McConnectionClient;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
const McConnectionShared = require('./mc-connection-shared');
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
class McConnectionServerShared extends McConnectionShared {
|
|
8
|
+
constructor(networkConnection, connectionName) {
|
|
9
|
+
super(networkConnection, connectionName);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
setRemoteAddress(remoteAddress) {
|
|
13
|
+
this.networkConnection.setRemoteAddress(remoteAddress);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
attach(socket) {
|
|
17
|
+
this.networkConnection.attach(socket);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
closed() {
|
|
21
|
+
return this.networkConnection.closed();
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
close(done) {
|
|
25
|
+
if(0 === this.unref()) {
|
|
26
|
+
this.networkConnection.close(done);
|
|
27
|
+
}
|
|
28
|
+
else {
|
|
29
|
+
process.nextTick(done);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
sendMessage(msg) {
|
|
34
|
+
this.networkConnection.sendMessage(msg);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
getRemoteAddress() {
|
|
38
|
+
return this.networkConnection.getRemoteAddress();
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
getRemotePort() {
|
|
42
|
+
return this.networkConnection.getRemotePort();
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
getRemoteFamily() {
|
|
46
|
+
return this.networkConnection.getRemoteFamily();
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
module.exports = McConnectionServerShared;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
const McConnection = require('./mc-connection');
|
|
5
|
+
const Dgram = require('dgram');
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class McConnectionServer extends McConnection {
|
|
9
|
+
constructor(srvAddress, dstAddress, mcServer, transportProperties, connection) {
|
|
10
|
+
super(transportProperties, 'server', connection);
|
|
11
|
+
this.srvAddress = srvAddress;
|
|
12
|
+
this.dstAddress = dstAddress;
|
|
13
|
+
this.mcServer = mcServer;
|
|
14
|
+
this.remoteAddress = null;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
setRemoteAddress(remoteAddress) {
|
|
18
|
+
this.remoteAddress = remoteAddress;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
attach(socket) {
|
|
22
|
+
this.socket = socket;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
closed() {
|
|
26
|
+
return this.mcServer.closed();
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
close(done) {
|
|
30
|
+
this.mcServer.closeConnection(this.remoteAddress);
|
|
31
|
+
process.nextTick(done);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
sendMessage(msg) {
|
|
35
|
+
this.mcServer.send(msg, this.remoteAddress);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
getRemoteAddress() {
|
|
39
|
+
if(null !== this.remoteAddress) {
|
|
40
|
+
return this.remoteAddress.host;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
getRemotePort() {
|
|
45
|
+
if(null !== this.remoteAddress) {
|
|
46
|
+
return this.remoteAddress.port;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
getRemoteFamily() {
|
|
51
|
+
if(null !== this.remoteAddress) {
|
|
52
|
+
return this.remoteAddress.family;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
module.exports = McConnectionServer;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
const NetworkConnectionShared = require('../network-connection-shared');
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
class McConnectionShared extends NetworkConnectionShared {
|
|
8
|
+
constructor(networkConnection, connectionName) {
|
|
9
|
+
super(networkConnection, connectionName);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
getLocalAddress() {
|
|
13
|
+
return this.networkConnection.getLocalAddress();
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
getLocalPort() {
|
|
17
|
+
return this.networkConnection.getLocalPort();
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
getLocalFamily() {
|
|
21
|
+
return this.networkConnection.getLocalFamily();
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
module.exports = McConnectionShared;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
const NetworkConnection = require('../network-connection');
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
class McConnection extends NetworkConnection {
|
|
8
|
+
constructor(transportProperties, type, connection) {
|
|
9
|
+
super(transportProperties, 'mc', type, connection);
|
|
10
|
+
this.socket = null;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
getLocalAddress() {
|
|
14
|
+
if(null !== this.socket) {
|
|
15
|
+
return this.socket.address().address;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
getLocalPort() {
|
|
20
|
+
if(null !== this.socket) {
|
|
21
|
+
return this.socket.address().port;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
getLocalFamily() {
|
|
26
|
+
if(null !== this.socket) {
|
|
27
|
+
return this.socket.address().family;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
module.exports = McConnection;
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
const NetworkServer = require('../network-server');
|
|
5
|
+
const Dgram = require('dgram');
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class McServer extends NetworkServer {
|
|
9
|
+
constructor(connection, cbConnection) {
|
|
10
|
+
super(connection, cbConnection, 'mc');
|
|
11
|
+
this.logicConnections = new Map();
|
|
12
|
+
this.isOpen = false;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
init(srvAddress, dstAddress, transportProperties, cbListen) {
|
|
16
|
+
this.srvAddress = srvAddress;
|
|
17
|
+
this.dstAddress = dstAddress;
|
|
18
|
+
if(!this.dstAddress) {
|
|
19
|
+
process.nextTick((cbListen) => {
|
|
20
|
+
cbListen(new Error('MC - A multicast server must have an dstAddress'));
|
|
21
|
+
}, cbListen);
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
if('IPv4' === this.dstAddress.family) {
|
|
25
|
+
this.serverSocket = Dgram.createSocket({type: 'udp4', reuseAddr: true});
|
|
26
|
+
}
|
|
27
|
+
else if('IPv6' === this.dstAddress.family) {
|
|
28
|
+
this.serverSocket = Dgram.createSocket({type: 'udp6', reuseAddr: true});
|
|
29
|
+
}
|
|
30
|
+
else {
|
|
31
|
+
process.nextTick((self, cbListen) => {
|
|
32
|
+
cbListen(new Error(`No accepted IP family; '${self.srvAddress.family}'`));
|
|
33
|
+
}, this, cbListen);
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
this.serverSocket.on('error', (err) => { // ??? Isn't this part of 'connection.attach'.
|
|
37
|
+
cbListen(err);
|
|
38
|
+
});
|
|
39
|
+
try {
|
|
40
|
+
this.serverSocket.bind({
|
|
41
|
+
port: this.srvAddress.port,
|
|
42
|
+
address: this.srvAddress.host,
|
|
43
|
+
exclusive: false
|
|
44
|
+
}, (err) => {
|
|
45
|
+
try {
|
|
46
|
+
this.serverSocket.setMulticastInterface(this.srvAddress.host);
|
|
47
|
+
this.serverSocket.setMulticastTTL(4);
|
|
48
|
+
}
|
|
49
|
+
catch(err) {
|
|
50
|
+
return cbListen(err);
|
|
51
|
+
}
|
|
52
|
+
this.isOpen = true;
|
|
53
|
+
cbListen();
|
|
54
|
+
process.nextTick((self) => {
|
|
55
|
+
const key = `${self.dstAddress.host}:${self.dstAddress.port}`;
|
|
56
|
+
const connection = self.cbConnection(self.serverSocket, {
|
|
57
|
+
name: '',
|
|
58
|
+
port: self.dstAddress.port,
|
|
59
|
+
host: self.dstAddress.host,
|
|
60
|
+
family: self.srvAddress.family,
|
|
61
|
+
type: 'client'
|
|
62
|
+
});
|
|
63
|
+
self.logicConnections.set(key, connection);
|
|
64
|
+
}, this);
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
catch(err) {
|
|
68
|
+
console.log('BIND:', err);
|
|
69
|
+
}
|
|
70
|
+
this.serverSocket.on('close', () => {
|
|
71
|
+
this.isOpen = false;
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
closed() {
|
|
76
|
+
return !this.isOpen;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
closeConnection(address) {
|
|
80
|
+
const key = `${address.address}:${address.port}`;
|
|
81
|
+
this.logicConnections.delete(key);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
send(msg, address) {
|
|
85
|
+
this.serverSocket.send(msg, address.port, address.host);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
module.exports = McServer;
|
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
const PendingInner = require('../pending/pending-inner');
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
class NetworkConnectionShared extends PendingInner {
|
|
8
|
+
constructor(networkConnection, connectionName) {
|
|
9
|
+
super(connectionName);
|
|
10
|
+
this.networkConnection = networkConnection;
|
|
11
|
+
this.connectionName = connectionName;
|
|
12
|
+
this.instances = 0;
|
|
13
|
+
this.sending = false;
|
|
14
|
+
this.sendLockQueue = [];
|
|
15
|
+
this.receiving = false;
|
|
16
|
+
this.receiveLockQueue = [];
|
|
17
|
+
this.receiveSelectorsQueue = new Set();
|
|
18
|
+
this.messagesQueue = new Set();
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
closed() {
|
|
22
|
+
return this.networkConnection.closed();
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
halfClosed() {
|
|
26
|
+
return this.networkConnection.closed();
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
sendLock(cbExecute) {
|
|
30
|
+
if(!this.sending) {
|
|
31
|
+
this.sending = true;
|
|
32
|
+
cbExecute();
|
|
33
|
+
}
|
|
34
|
+
else {
|
|
35
|
+
this.sendLockQueue.push({
|
|
36
|
+
cbExecute
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
sendUnlock() {
|
|
42
|
+
if(0 === this.sendLockQueue.length) {
|
|
43
|
+
this.sending = false;
|
|
44
|
+
}
|
|
45
|
+
else {
|
|
46
|
+
process.nextTick((self) => {
|
|
47
|
+
const sendLockData = self.sendLockQueue.shift();
|
|
48
|
+
sendLockData.cbExecute();
|
|
49
|
+
}, this);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
send(msg, done) {
|
|
54
|
+
this.networkConnection.send(msg, () => {
|
|
55
|
+
done();
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
receiveLine(done) {
|
|
60
|
+
this.networkConnection.receiveLine(done);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
receiveSize(size, done) {
|
|
64
|
+
this.networkConnection.receiveSize(size, done);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
receiveLock(cbExecute) {
|
|
68
|
+
if(!this.receiving) {
|
|
69
|
+
this.receiving = true;
|
|
70
|
+
cbExecute();
|
|
71
|
+
}
|
|
72
|
+
else {
|
|
73
|
+
this.receiveLockQueue.push({
|
|
74
|
+
cbExecute: cbExecute
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
receiveUnlock() {
|
|
80
|
+
if(0 === this.receiveLockQueue.length) {
|
|
81
|
+
this.receiving = false;
|
|
82
|
+
}
|
|
83
|
+
else {
|
|
84
|
+
process.nextTick((self) => {
|
|
85
|
+
const receivingData = self.receiveLockQueue.shift();
|
|
86
|
+
receivingData.cbExecute();
|
|
87
|
+
}, this);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
addReceiveSelector(sharedMessageSelector, cbMessage) {
|
|
92
|
+
this.receiveSelectorsQueue.add({
|
|
93
|
+
sharedMessageSelector: sharedMessageSelector,
|
|
94
|
+
cbMessage: cbMessage
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
addReceivedMessage(msg) {
|
|
99
|
+
this.messagesQueue.add(msg);
|
|
100
|
+
this.messagesQueue.forEach((msg) => {
|
|
101
|
+
this.receiveSelectorsQueue.forEach((receiveSelector) => {
|
|
102
|
+
if(!receiveSelector.sharedMessageSelector || receiveSelector.sharedMessageSelector._select(msg)) {
|
|
103
|
+
const selectedMsg = msg;
|
|
104
|
+
const selectedReceiveSelector = receiveSelector;
|
|
105
|
+
process.nextTick((self, selectedMsg, selectedReceiveSelector) => {
|
|
106
|
+
self.messagesQueue.delete(selectedMsg);
|
|
107
|
+
self.receiveSelectorsQueue.delete(selectedReceiveSelector);
|
|
108
|
+
selectedReceiveSelector.cbMessage(selectedMsg);
|
|
109
|
+
}, this, selectedMsg, selectedReceiveSelector);
|
|
110
|
+
}
|
|
111
|
+
});
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
cancel() {
|
|
116
|
+
this.networkConnection.cancel();
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
onBuffer(buffer) {
|
|
120
|
+
this.networkConnection.onBuffer(buffer);
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
ref() {
|
|
124
|
+
return ++this.instances;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
unref() {
|
|
128
|
+
return --this.instances;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
getSrvAddress() {
|
|
132
|
+
return this.networkConnection.srvAddress;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
getDstAddress() {
|
|
136
|
+
return this.networkConnection.dstAddress;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
logEngine(message, group, guid, depth=3) {
|
|
140
|
+
this.networkConnection.connection.logEngine(message, group, guid, depth);
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
logDebug(message, group, guid, depth=3) {
|
|
144
|
+
this.networkConnection.connection.logDebug(message, group, guid, depth);
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
logError(errOrMsg, guid, depth=3) {
|
|
148
|
+
this.networkConnection.connection.logError(errOrMsg, guid, depth);
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
isLogIp() {
|
|
152
|
+
return this.networkConnection.connection.isLogIp();
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
logIp(log, group, guid, depth=3) {
|
|
156
|
+
this.networkConnection.connection.logIp(log, group, guid, depth);
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
isLogGui(group) {
|
|
160
|
+
return this.networkConnection.connection.isLogGui(group);
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
logGui(log, group, guid, depth=3) {
|
|
164
|
+
this.networkConnection.connection.logGui(log, group, guid, depth);
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
logWarning(message, group, guid, depth=3) {
|
|
168
|
+
this.networkConnection.connection.logWarning(message, group, guid, depth);
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
logTestData(message, group, guid, depth=3) {
|
|
172
|
+
this.networkConnection.connection.logTestData(message, group, guid, depth);
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
|
|
177
|
+
module.exports = NetworkConnectionShared;
|