thor-io.vnext 2.0.5-beta.3 → 3.1.0-beta.1
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 +17 -17
- package/build/index.d.ts +24 -0
- package/build/index.js +47 -0
- package/build/src/Connection/ClientInfo.d.ts +27 -0
- package/{src/Client → build/src/Connection}/ClientInfo.js +7 -0
- package/build/src/Connection/Connection.d.ts +117 -0
- package/build/src/Connection/Connection.js +202 -0
- package/build/src/Connection/IClientInfo.d.ts +20 -0
- package/build/src/Controller/ControllerBase.d.ts +134 -0
- package/build/src/Controller/ControllerBase.js +543 -0
- package/build/src/Controller/Subscription.d.ts +27 -0
- package/build/src/Controller/Subscription.js +22 -0
- package/build/src/Controllers/BrokerController/Broker.js +145 -0
- package/build/src/Controllers/BrokerController/BrokerController.d.ts +61 -0
- package/build/src/Controllers/BrokerController/BrokerController.js +115 -0
- package/{src/Controllers/BrokerController/Broker.js → build/src/Controllers/BrokerController/BrokerrController.js} +74 -85
- package/build/src/Controllers/BrokerController/Models/PeerConnection.d.ts +7 -0
- package/build/src/Controllers/BrokerController/Models/PeerConnection.js +14 -0
- package/build/src/Controllers/BrokerController/Models/Signal.js +11 -0
- package/build/src/Decorators/CanInvoke.d.ts +10 -0
- package/build/src/Decorators/CanInvoke.js +22 -0
- package/build/src/Decorators/CanSet.d.ts +10 -0
- package/build/src/Decorators/CanSet.js +20 -0
- package/build/src/Decorators/ControllerProperties.d.ts +10 -0
- package/build/src/Decorators/ControllerProperties.js +20 -0
- package/{src/Controllers/BrokerController/Models/InstantMessage.js → build/src/Interfaces/IInterceptor.js} +2 -5
- package/build/src/Interfaces/ITransport.d.ts +94 -0
- package/build/src/Interfaces/ITransportMessage.d.ts +41 -0
- package/build/src/Messages/BufferMessage.d.ts +38 -0
- package/{src → build/src}/Messages/BufferMessage.js +32 -2
- package/build/src/Messages/ErrorMessage.d.ts +29 -0
- package/build/src/Messages/ErrorMessage.js +22 -0
- package/build/src/Messages/PipeMessage.d.ts +46 -0
- package/build/src/Messages/PipeMessage.js +41 -0
- package/build/src/Messages/TextMessage.d.ts +88 -0
- package/build/src/Messages/TextMessage.js +94 -0
- package/build/src/Messages/WebSocketMessage.d.ts +34 -0
- package/build/src/Messages/WebSocketMessage.js +41 -0
- package/build/src/Plugin.js +32 -0
- package/build/src/Server/Plugin.d.ts +37 -0
- package/build/src/Server/Plugin.js +32 -0
- package/build/src/Server/ThorIOServer.d.ts +68 -0
- package/build/src/Server/ThorIOServer.js +131 -0
- package/build/src/Subscription.js +22 -0
- package/build/src/ThorIO.js +142 -0
- package/build/src/ThorIOServer.d.ts +64 -0
- package/build/src/ThorIOServer.js +131 -0
- package/build/src/Transports/BufferMessageTransport.d.ts +78 -0
- package/build/src/Transports/BufferMessageTransport.js +85 -0
- package/build/src/Transports/PipeMessageTransport.d.ts +79 -0
- package/build/src/Transports/PipeMessageTransport.js +90 -0
- package/build/src/Transports/WebSocketMessageTransport.d.ts +87 -0
- package/build/src/Transports/WebSocketMessageTransport.js +93 -0
- package/build/src/Utils/BufferUtils.d.ts +32 -0
- package/build/src/Utils/BufferUtils.js +57 -0
- package/build/src/Utils/StringUtils.d.ts +15 -0
- package/build/src/Utils/StringUtils.js +31 -0
- package/build/src/test.js +5 -0
- package/docs/.nojekyll +1 -0
- package/docs/assets/hierarchy.js +1 -0
- package/docs/assets/highlight.css +43 -0
- package/docs/assets/icons.js +18 -0
- package/docs/assets/icons.svg +1 -0
- package/docs/assets/main.js +60 -0
- package/docs/assets/navigation.js +1 -0
- package/docs/assets/search.js +1 -0
- package/docs/assets/style.css +1610 -0
- package/docs/classes/BrokerController.html +164 -0
- package/docs/classes/BufferMessage.html +11 -0
- package/docs/classes/BufferMessageTransport.html +31 -0
- package/docs/classes/BufferUtils.html +16 -0
- package/docs/classes/ClientInfo.html +11 -0
- package/docs/classes/Connection.html +42 -0
- package/docs/classes/ControllerBase.html +144 -0
- package/docs/classes/ErrorMessage.html +13 -0
- package/docs/classes/PeerConnection.html +4 -0
- package/docs/classes/PipeMessage.html +17 -0
- package/docs/classes/PipeMessageTransport.html +33 -0
- package/docs/classes/Plugin.html +13 -0
- package/docs/classes/Signal.html +5 -0
- package/docs/classes/StringUtils.html +9 -0
- package/docs/classes/Subscription.html +11 -0
- package/docs/classes/TextMessage.html +37 -0
- package/docs/classes/ThorIOServer.html +25 -0
- package/docs/classes/WebSocketMessage.html +18 -0
- package/docs/classes/WebSocketMessageTransport.html +35 -0
- package/docs/functions/CanInvoke.html +5 -0
- package/docs/functions/CanSet.html +5 -0
- package/docs/functions/ControllerProperties.html +5 -0
- package/docs/hierarchy.html +1 -0
- package/docs/index.html +24 -0
- package/docs/interfaces/ITransport.html +46 -0
- package/docs/interfaces/ITransportMessage.html +21 -0
- package/docs/modules.html +1 -0
- package/index.ts +32 -37
- package/licence +21 -21
- package/package.json +48 -50
- package/readme.md +32 -1
- package/src/{Client → Connection}/ClientInfo.ts +34 -43
- package/src/Connection/Connection.ts +229 -0
- package/src/Connection/IClientInfo.ts +22 -0
- package/src/Controller/ControllerBase.ts +561 -457
- package/src/{Subscription.ts → Controller/Subscription.ts} +32 -34
- package/src/Controllers/BrokerController/BrokerController.ts +121 -0
- package/src/Controllers/BrokerController/Models/PeerConnection.ts +12 -34
- package/src/Controllers/BrokerController/Models/Signal.ts +11 -43
- package/src/Decorators/CanInvoke.ts +21 -13
- package/src/Decorators/CanSet.ts +19 -12
- package/src/Decorators/ControllerProperties.ts +19 -16
- package/src/Interfaces/ITransport.ts +107 -23
- package/src/Interfaces/ITransportMessage.ts +45 -41
- package/src/Messages/BufferMessage.ts +70 -69
- package/src/Messages/ErrorMessage.ts +34 -6
- package/src/Messages/PipeMessage.ts +56 -62
- package/src/Messages/TextMessage.ts +139 -93
- package/src/Messages/WebSocketMessage.ts +39 -41
- package/src/Server/Plugin.ts +56 -0
- package/src/Server/ThorIOServer.ts +121 -0
- package/src/ThorIOServer.ts +117 -0
- package/src/Transports/BufferMessageTransport.ts +109 -100
- package/src/Transports/PipeMessageTransport.ts +112 -104
- package/src/Transports/WebSocketMessageTransport.ts +122 -110
- package/src/Utils/BufferUtils.ts +55 -61
- package/src/Utils/StringUtils.ts +28 -17
- package/tsconfig.json +109 -19
- package/typedoc.json +6 -0
- package/index.d.ts +0 -24
- package/index.js +0 -46
- package/src/Client/ClientInfo.d.ts +0 -6
- package/src/Connection.d.ts +0 -24
- package/src/Connection.js +0 -121
- package/src/Connection.ts +0 -263
- package/src/Controller/ControllerBase.d.ts +0 -43
- package/src/Controller/ControllerBase.js +0 -331
- package/src/Controllers/BrokerController/Broker.d.ts +0 -21
- package/src/Controllers/BrokerController/Broker.ts +0 -153
- package/src/Controllers/BrokerController/Models/InstantMessage.d.ts +0 -3
- package/src/Controllers/BrokerController/Models/InstantMessage.ts +0 -15
- package/src/Controllers/BrokerController/Models/PeerConnection.d.ts +0 -5
- package/src/Controllers/BrokerController/Models/PeerConnection.js +0 -9
- package/src/Controllers/BrokerController/Models/Signal.js +0 -10
- package/src/Decorators/CanInvoke.d.ts +0 -2
- package/src/Decorators/CanInvoke.js +0 -9
- package/src/Decorators/CanSet.d.ts +0 -1
- package/src/Decorators/CanSet.js +0 -8
- package/src/Decorators/ControllerProperties.d.ts +0 -1
- package/src/Decorators/ControllerProperties.js +0 -10
- package/src/Interfaces/IInterceptor.d.ts +0 -2
- package/src/Interfaces/IInterceptor.ts +0 -2
- package/src/Interfaces/ITransport.d.ts +0 -18
- package/src/Interfaces/ITransportMessage.d.ts +0 -8
- package/src/Listener.d.ts +0 -5
- package/src/Listener.js +0 -9
- package/src/Listener.ts +0 -34
- package/src/Messages/BufferMessage.d.ts +0 -10
- package/src/Messages/ErrorMessage.d.ts +0 -4
- package/src/Messages/ErrorMessage.js +0 -8
- package/src/Messages/PipeMessage.d.ts +0 -12
- package/src/Messages/PipeMessage.js +0 -20
- package/src/Messages/TextMessage.d.ts +0 -15
- package/src/Messages/TextMessage.js +0 -50
- package/src/Messages/WebSocketMessage.d.ts +0 -10
- package/src/Messages/WebSocketMessage.js +0 -15
- package/src/Plugin.d.ts +0 -6
- package/src/Plugin.js +0 -11
- package/src/Plugin.ts +0 -37
- package/src/Subscription.d.ts +0 -5
- package/src/Subscription.js +0 -9
- package/src/ThorIO.d.ts +0 -18
- package/src/ThorIO.js +0 -65
- package/src/ThorIO.ts +0 -148
- package/src/Transports/BufferMessageTransport.d.ts +0 -21
- package/src/Transports/BufferMessageTransport.js +0 -31
- package/src/Transports/PipeMessageTransport.d.ts +0 -20
- package/src/Transports/PipeMessageTransport.js +0 -33
- package/src/Transports/WebSocketMessageTransport.d.ts +0 -20
- package/src/Transports/WebSocketMessageTransport.js +0 -31
- package/src/Utils/BufferUtils.d.ts +0 -5
- package/src/Utils/BufferUtils.js +0 -29
- package/src/Utils/StringUtils.d.ts +0 -4
- package/src/Utils/StringUtils.js +0 -13
- /package/{src/Interfaces/IInterceptor.js → build/src/Connection/IClientInfo.js} +0 -0
- /package/{src → build/src}/Controllers/BrokerController/Models/Signal.d.ts +0 -0
- /package/{src → build/src}/Interfaces/ITransport.js +0 -0
- /package/{src → build/src}/Interfaces/ITransportMessage.js +0 -0
|
@@ -1,331 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
-
};
|
|
8
|
-
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
const CanInvoke_1 = require("../Decorators/CanInvoke");
|
|
13
|
-
const CanSet_1 = require("../Decorators/CanSet");
|
|
14
|
-
const TextMessage_1 = require("../Messages/TextMessage");
|
|
15
|
-
const Connection_1 = require("../Connection");
|
|
16
|
-
const Subscription_1 = require("../Subscription");
|
|
17
|
-
const ErrorMessage_1 = require("../Messages/ErrorMessage");
|
|
18
|
-
const url_1 = require("url");
|
|
19
|
-
class ControllerBase {
|
|
20
|
-
constructor(connection) {
|
|
21
|
-
this.connection = connection;
|
|
22
|
-
this.subscriptions = [];
|
|
23
|
-
this.alias = Reflect.getMetadata("alias", this.constructor);
|
|
24
|
-
this.heartbeatInterval = Reflect.getMetadata("heartbeatInterval", this.constructor);
|
|
25
|
-
if (this.heartbeatInterval >= 1000)
|
|
26
|
-
this.enableHeartbeat();
|
|
27
|
-
}
|
|
28
|
-
enableHeartbeat() {
|
|
29
|
-
this.connection.transport.addEventListener("pong", () => {
|
|
30
|
-
this.lastPong = new Date();
|
|
31
|
-
});
|
|
32
|
-
this.interval = setInterval(() => {
|
|
33
|
-
this.lastPing = new Date();
|
|
34
|
-
if (this.connection.transport.readyState === 1)
|
|
35
|
-
this.connection.transport.ping();
|
|
36
|
-
}, this.heartbeatInterval);
|
|
37
|
-
}
|
|
38
|
-
disbaleHeartbeat() {
|
|
39
|
-
clearInterval(this.interval);
|
|
40
|
-
}
|
|
41
|
-
canInvokeMethod(method) {
|
|
42
|
-
return Reflect.getMetadata("canInvokeOrSet", this, method);
|
|
43
|
-
}
|
|
44
|
-
findOn(alias, predicate) {
|
|
45
|
-
let connections = this.getConnections(alias).map((p) => {
|
|
46
|
-
return p.getController(alias);
|
|
47
|
-
});
|
|
48
|
-
return connections.filter(predicate);
|
|
49
|
-
}
|
|
50
|
-
getConnections(alias) {
|
|
51
|
-
if (!alias) {
|
|
52
|
-
return Array.from(this.connection.connections.values());
|
|
53
|
-
}
|
|
54
|
-
else {
|
|
55
|
-
return Array.from(this.connection.connections.values()).map((conn) => {
|
|
56
|
-
if (conn.hasController(this.alias))
|
|
57
|
-
return conn;
|
|
58
|
-
});
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
onopen() { }
|
|
62
|
-
onclose() { }
|
|
63
|
-
find(array, predicate, selector = (x) => x) {
|
|
64
|
-
return array.filter(predicate).map(selector);
|
|
65
|
-
}
|
|
66
|
-
invokeError(ex) {
|
|
67
|
-
let errorMessage = new ErrorMessage_1.ErrorMessage(ex.message);
|
|
68
|
-
this.invoke(errorMessage, "___error", this.alias);
|
|
69
|
-
}
|
|
70
|
-
invokeToOthers(data, topic, controller, buffer) {
|
|
71
|
-
this.getConnections().filter((pre) => {
|
|
72
|
-
return pre.id !== this.connection.id;
|
|
73
|
-
})
|
|
74
|
-
.forEach((connection) => {
|
|
75
|
-
connection.getController(controller || this.alias).invoke(data, topic, controller || this.alias, buffer);
|
|
76
|
-
});
|
|
77
|
-
}
|
|
78
|
-
invokeToAll(data, topic, controller, buffer) {
|
|
79
|
-
this.getConnections().forEach((connection) => {
|
|
80
|
-
connection.getController(controller || this.alias).invoke(data, topic, controller || this.alias, buffer);
|
|
81
|
-
});
|
|
82
|
-
}
|
|
83
|
-
invokeTo(predicate, data, topic, controller, buffer) {
|
|
84
|
-
let connections = this.findOn(controller || this.alias, predicate);
|
|
85
|
-
connections.forEach((ctrl) => {
|
|
86
|
-
ctrl.invoke(data, topic, controller || this.alias, buffer);
|
|
87
|
-
});
|
|
88
|
-
}
|
|
89
|
-
invoke(data, topic, controller, buffer) {
|
|
90
|
-
let msg = new TextMessage_1.TextMessage(topic, data, controller || this.alias, buffer);
|
|
91
|
-
if (this.connection.transport)
|
|
92
|
-
this.connection.transport.send(!msg.isBinary ? msg.toString() : msg.toArrayBuffer());
|
|
93
|
-
return this;
|
|
94
|
-
}
|
|
95
|
-
publish(data, topic, controller) {
|
|
96
|
-
if (!this.hasSubscription(topic))
|
|
97
|
-
return;
|
|
98
|
-
return this.invoke(data, topic, controller || this.alias);
|
|
99
|
-
}
|
|
100
|
-
publishToAll(data, topic, controller) {
|
|
101
|
-
let msg = new TextMessage_1.TextMessage(topic, data, this.alias);
|
|
102
|
-
this.getConnections().forEach((connection) => {
|
|
103
|
-
let ctrl = connection.getController(controller || this.alias);
|
|
104
|
-
if (ctrl.getSubscription(topic)) {
|
|
105
|
-
connection.transport.send(msg.toString());
|
|
106
|
-
}
|
|
107
|
-
});
|
|
108
|
-
}
|
|
109
|
-
hasSubscription(topic) {
|
|
110
|
-
let p = this.subscriptions.filter((pre) => {
|
|
111
|
-
return pre.topic === topic;
|
|
112
|
-
});
|
|
113
|
-
return !(p.length === 0);
|
|
114
|
-
}
|
|
115
|
-
addSubscription(topic) {
|
|
116
|
-
let subscription = new Subscription_1.Subscription(topic, this.alias);
|
|
117
|
-
return this.___subscribe(subscription, topic, this.alias);
|
|
118
|
-
}
|
|
119
|
-
removeSubscription(topic) {
|
|
120
|
-
return this.___unsubscribe(this.getSubscription(topic));
|
|
121
|
-
}
|
|
122
|
-
getSubscription(topic) {
|
|
123
|
-
let subscription = this.subscriptions.find((pre) => {
|
|
124
|
-
return pre.topic === topic;
|
|
125
|
-
});
|
|
126
|
-
return subscription;
|
|
127
|
-
}
|
|
128
|
-
___connect() {
|
|
129
|
-
}
|
|
130
|
-
___close() {
|
|
131
|
-
this.connection.removeController(this.alias);
|
|
132
|
-
this.invoke({}, " ___close", this.alias);
|
|
133
|
-
}
|
|
134
|
-
___subscribe(subscription, topic, controller) {
|
|
135
|
-
if (this.hasSubscription(subscription.topic)) {
|
|
136
|
-
return;
|
|
137
|
-
}
|
|
138
|
-
this.subscriptions.push(subscription);
|
|
139
|
-
return subscription;
|
|
140
|
-
}
|
|
141
|
-
___unsubscribe(subscription) {
|
|
142
|
-
let index = this.subscriptions.indexOf(this.getSubscription(subscription.topic));
|
|
143
|
-
if (index >= 0) {
|
|
144
|
-
let result = this.subscriptions.splice(index, 1);
|
|
145
|
-
return true;
|
|
146
|
-
}
|
|
147
|
-
else
|
|
148
|
-
return false;
|
|
149
|
-
}
|
|
150
|
-
get queryParameters() {
|
|
151
|
-
return new url_1.URLSearchParams(this.request.url.replace("/?", ""));
|
|
152
|
-
}
|
|
153
|
-
get headers() {
|
|
154
|
-
let headers = new Map();
|
|
155
|
-
try {
|
|
156
|
-
Object.keys(this.connection.transport.request["headers"]).forEach(k => {
|
|
157
|
-
headers.set(k, this.connection.transport.request["headers"][k]);
|
|
158
|
-
});
|
|
159
|
-
}
|
|
160
|
-
catch (_a) {
|
|
161
|
-
return headers;
|
|
162
|
-
}
|
|
163
|
-
return headers;
|
|
164
|
-
}
|
|
165
|
-
get request() {
|
|
166
|
-
return this.connection.transport.request;
|
|
167
|
-
}
|
|
168
|
-
}
|
|
169
|
-
__decorate([
|
|
170
|
-
CanSet_1.CanSet(false),
|
|
171
|
-
__metadata("design:type", String)
|
|
172
|
-
], ControllerBase.prototype, "alias", void 0);
|
|
173
|
-
__decorate([
|
|
174
|
-
CanSet_1.CanSet(false),
|
|
175
|
-
__metadata("design:type", Array)
|
|
176
|
-
], ControllerBase.prototype, "subscriptions", void 0);
|
|
177
|
-
__decorate([
|
|
178
|
-
CanSet_1.CanSet(false),
|
|
179
|
-
__metadata("design:type", Connection_1.Connection)
|
|
180
|
-
], ControllerBase.prototype, "connection", void 0);
|
|
181
|
-
__decorate([
|
|
182
|
-
CanSet_1.CanSet(false),
|
|
183
|
-
__metadata("design:type", Date)
|
|
184
|
-
], ControllerBase.prototype, "lastPong", void 0);
|
|
185
|
-
__decorate([
|
|
186
|
-
CanSet_1.CanSet(false),
|
|
187
|
-
__metadata("design:type", Date)
|
|
188
|
-
], ControllerBase.prototype, "lastPing", void 0);
|
|
189
|
-
__decorate([
|
|
190
|
-
CanSet_1.CanSet(false),
|
|
191
|
-
__metadata("design:type", Number)
|
|
192
|
-
], ControllerBase.prototype, "heartbeatInterval", void 0);
|
|
193
|
-
__decorate([
|
|
194
|
-
CanInvoke_1.CanInvoke(false),
|
|
195
|
-
__metadata("design:type", Function),
|
|
196
|
-
__metadata("design:paramtypes", []),
|
|
197
|
-
__metadata("design:returntype", void 0)
|
|
198
|
-
], ControllerBase.prototype, "enableHeartbeat", null);
|
|
199
|
-
__decorate([
|
|
200
|
-
CanInvoke_1.CanInvoke(false),
|
|
201
|
-
__metadata("design:type", Function),
|
|
202
|
-
__metadata("design:paramtypes", []),
|
|
203
|
-
__metadata("design:returntype", void 0)
|
|
204
|
-
], ControllerBase.prototype, "disbaleHeartbeat", null);
|
|
205
|
-
__decorate([
|
|
206
|
-
CanInvoke_1.CanInvoke(false),
|
|
207
|
-
__metadata("design:type", Function),
|
|
208
|
-
__metadata("design:paramtypes", [String]),
|
|
209
|
-
__metadata("design:returntype", Boolean)
|
|
210
|
-
], ControllerBase.prototype, "canInvokeMethod", null);
|
|
211
|
-
__decorate([
|
|
212
|
-
CanInvoke_1.CanInvoke(false),
|
|
213
|
-
__metadata("design:type", Function),
|
|
214
|
-
__metadata("design:paramtypes", [String, Function]),
|
|
215
|
-
__metadata("design:returntype", Array)
|
|
216
|
-
], ControllerBase.prototype, "findOn", null);
|
|
217
|
-
__decorate([
|
|
218
|
-
CanInvoke_1.CanInvoke(false),
|
|
219
|
-
__metadata("design:type", Function),
|
|
220
|
-
__metadata("design:paramtypes", [String]),
|
|
221
|
-
__metadata("design:returntype", Array)
|
|
222
|
-
], ControllerBase.prototype, "getConnections", null);
|
|
223
|
-
__decorate([
|
|
224
|
-
CanInvoke_1.CanInvoke(false),
|
|
225
|
-
__metadata("design:type", Function),
|
|
226
|
-
__metadata("design:paramtypes", []),
|
|
227
|
-
__metadata("design:returntype", void 0)
|
|
228
|
-
], ControllerBase.prototype, "onopen", null);
|
|
229
|
-
__decorate([
|
|
230
|
-
CanInvoke_1.CanInvoke(false),
|
|
231
|
-
__metadata("design:type", Function),
|
|
232
|
-
__metadata("design:paramtypes", []),
|
|
233
|
-
__metadata("design:returntype", void 0)
|
|
234
|
-
], ControllerBase.prototype, "onclose", null);
|
|
235
|
-
__decorate([
|
|
236
|
-
CanInvoke_1.CanInvoke(false),
|
|
237
|
-
__metadata("design:type", Function),
|
|
238
|
-
__metadata("design:paramtypes", [Array, Function, Function]),
|
|
239
|
-
__metadata("design:returntype", Array)
|
|
240
|
-
], ControllerBase.prototype, "find", null);
|
|
241
|
-
__decorate([
|
|
242
|
-
CanInvoke_1.CanInvoke(false),
|
|
243
|
-
__metadata("design:type", Function),
|
|
244
|
-
__metadata("design:paramtypes", [Object]),
|
|
245
|
-
__metadata("design:returntype", void 0)
|
|
246
|
-
], ControllerBase.prototype, "invokeError", null);
|
|
247
|
-
__decorate([
|
|
248
|
-
CanInvoke_1.CanInvoke(false),
|
|
249
|
-
__metadata("design:type", Function),
|
|
250
|
-
__metadata("design:paramtypes", [Object, String, String, Object]),
|
|
251
|
-
__metadata("design:returntype", void 0)
|
|
252
|
-
], ControllerBase.prototype, "invokeToOthers", null);
|
|
253
|
-
__decorate([
|
|
254
|
-
CanInvoke_1.CanInvoke(false),
|
|
255
|
-
__metadata("design:type", Function),
|
|
256
|
-
__metadata("design:paramtypes", [Object, String, String, Object]),
|
|
257
|
-
__metadata("design:returntype", void 0)
|
|
258
|
-
], ControllerBase.prototype, "invokeToAll", null);
|
|
259
|
-
__decorate([
|
|
260
|
-
CanInvoke_1.CanInvoke(false),
|
|
261
|
-
__metadata("design:type", Function),
|
|
262
|
-
__metadata("design:paramtypes", [Function, Object, String, String, Object]),
|
|
263
|
-
__metadata("design:returntype", void 0)
|
|
264
|
-
], ControllerBase.prototype, "invokeTo", null);
|
|
265
|
-
__decorate([
|
|
266
|
-
CanInvoke_1.CanInvoke(false),
|
|
267
|
-
__metadata("design:type", Function),
|
|
268
|
-
__metadata("design:paramtypes", [Object, String, String, Object]),
|
|
269
|
-
__metadata("design:returntype", ControllerBase)
|
|
270
|
-
], ControllerBase.prototype, "invoke", null);
|
|
271
|
-
__decorate([
|
|
272
|
-
CanInvoke_1.CanInvoke(false),
|
|
273
|
-
__metadata("design:type", Function),
|
|
274
|
-
__metadata("design:paramtypes", [Object, String, String]),
|
|
275
|
-
__metadata("design:returntype", ControllerBase)
|
|
276
|
-
], ControllerBase.prototype, "publish", null);
|
|
277
|
-
__decorate([
|
|
278
|
-
CanInvoke_1.CanInvoke(false),
|
|
279
|
-
__metadata("design:type", Function),
|
|
280
|
-
__metadata("design:paramtypes", [Object, String, String]),
|
|
281
|
-
__metadata("design:returntype", void 0)
|
|
282
|
-
], ControllerBase.prototype, "publishToAll", null);
|
|
283
|
-
__decorate([
|
|
284
|
-
CanInvoke_1.CanInvoke(false),
|
|
285
|
-
__metadata("design:type", Function),
|
|
286
|
-
__metadata("design:paramtypes", [String]),
|
|
287
|
-
__metadata("design:returntype", Boolean)
|
|
288
|
-
], ControllerBase.prototype, "hasSubscription", null);
|
|
289
|
-
__decorate([
|
|
290
|
-
CanInvoke_1.CanInvoke(false),
|
|
291
|
-
__metadata("design:type", Function),
|
|
292
|
-
__metadata("design:paramtypes", [String]),
|
|
293
|
-
__metadata("design:returntype", Subscription_1.Subscription)
|
|
294
|
-
], ControllerBase.prototype, "addSubscription", null);
|
|
295
|
-
__decorate([
|
|
296
|
-
CanInvoke_1.CanInvoke(false),
|
|
297
|
-
__metadata("design:type", Function),
|
|
298
|
-
__metadata("design:paramtypes", [String]),
|
|
299
|
-
__metadata("design:returntype", void 0)
|
|
300
|
-
], ControllerBase.prototype, "removeSubscription", null);
|
|
301
|
-
__decorate([
|
|
302
|
-
CanInvoke_1.CanInvoke(false),
|
|
303
|
-
__metadata("design:type", Function),
|
|
304
|
-
__metadata("design:paramtypes", [String]),
|
|
305
|
-
__metadata("design:returntype", Subscription_1.Subscription)
|
|
306
|
-
], ControllerBase.prototype, "getSubscription", null);
|
|
307
|
-
__decorate([
|
|
308
|
-
CanInvoke_1.CanInvoke(true),
|
|
309
|
-
__metadata("design:type", Function),
|
|
310
|
-
__metadata("design:paramtypes", []),
|
|
311
|
-
__metadata("design:returntype", void 0)
|
|
312
|
-
], ControllerBase.prototype, "___connect", null);
|
|
313
|
-
__decorate([
|
|
314
|
-
CanInvoke_1.CanInvoke(true),
|
|
315
|
-
__metadata("design:type", Function),
|
|
316
|
-
__metadata("design:paramtypes", []),
|
|
317
|
-
__metadata("design:returntype", void 0)
|
|
318
|
-
], ControllerBase.prototype, "___close", null);
|
|
319
|
-
__decorate([
|
|
320
|
-
CanInvoke_1.CanInvoke(true),
|
|
321
|
-
__metadata("design:type", Function),
|
|
322
|
-
__metadata("design:paramtypes", [Subscription_1.Subscription, String, String]),
|
|
323
|
-
__metadata("design:returntype", Subscription_1.Subscription)
|
|
324
|
-
], ControllerBase.prototype, "___subscribe", null);
|
|
325
|
-
__decorate([
|
|
326
|
-
CanInvoke_1.CanInvoke(true),
|
|
327
|
-
__metadata("design:type", Function),
|
|
328
|
-
__metadata("design:paramtypes", [Subscription_1.Subscription]),
|
|
329
|
-
__metadata("design:returntype", Boolean)
|
|
330
|
-
], ControllerBase.prototype, "___unsubscribe", null);
|
|
331
|
-
exports.ControllerBase = ControllerBase;
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { Connection } from '../../Connection';
|
|
2
|
-
import { PeerConnection } from './Models/PeerConnection';
|
|
3
|
-
import { Signal } from './Models/Signal';
|
|
4
|
-
import { ControllerBase } from '../../Controller/ControllerBase';
|
|
5
|
-
export interface IControllerBase {
|
|
6
|
-
onopen(e: any): void;
|
|
7
|
-
onclose(e: any): void;
|
|
8
|
-
}
|
|
9
|
-
export declare class BrokerController extends ControllerBase implements IControllerBase {
|
|
10
|
-
Connections: Array<PeerConnection>;
|
|
11
|
-
Peer: PeerConnection;
|
|
12
|
-
localPeerId: string;
|
|
13
|
-
Signal: any;
|
|
14
|
-
constructor(connection: Connection);
|
|
15
|
-
onopen(): void;
|
|
16
|
-
instantMessage(data: any, topic: string, controller: string): void;
|
|
17
|
-
changeContext(change: PeerConnection): void;
|
|
18
|
-
contextSignal(signal: Signal): void;
|
|
19
|
-
connectContext(): void;
|
|
20
|
-
getPeerConnections(peerConnetion: PeerConnection): Array<ControllerBase>;
|
|
21
|
-
}
|
|
@@ -1,153 +0,0 @@
|
|
|
1
|
-
import { CanInvoke } from '../../Decorators/CanInvoke';
|
|
2
|
-
import { Connection } from '../../Connection';
|
|
3
|
-
import { ControllerProperties } from '../../Decorators/ControllerProperties';
|
|
4
|
-
import { PeerConnection } from './Models/PeerConnection';
|
|
5
|
-
import { Signal } from './Models/Signal';
|
|
6
|
-
import { StringUtils } from '../../Utils/StringUtils';
|
|
7
|
-
import { ControllerBase } from '../../Controller/ControllerBase';
|
|
8
|
-
|
|
9
|
-
export interface IControllerBase{
|
|
10
|
-
onopen(e:any):void;
|
|
11
|
-
onclose(e:any):void;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
* @export
|
|
18
|
-
* @class BrokerController
|
|
19
|
-
* @extends {ControllerBase}
|
|
20
|
-
*/
|
|
21
|
-
@ControllerProperties("contextBroker", false, 7500)
|
|
22
|
-
export class BrokerController extends ControllerBase implements IControllerBase {
|
|
23
|
-
/**
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
* @type {Array<PeerConnection>}
|
|
27
|
-
* @memberOf BrokerController
|
|
28
|
-
*/
|
|
29
|
-
public Connections: Array<PeerConnection>;
|
|
30
|
-
/**
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
-
* @type {PeerConnection}
|
|
34
|
-
* @memberOf BrokerController
|
|
35
|
-
*/
|
|
36
|
-
public Peer: PeerConnection;
|
|
37
|
-
/**
|
|
38
|
-
*
|
|
39
|
-
*
|
|
40
|
-
* @type {string}
|
|
41
|
-
* @memberOf BrokerController
|
|
42
|
-
*/
|
|
43
|
-
public localPeerId: string;Signal
|
|
44
|
-
/**
|
|
45
|
-
* Creates an instance of BrokerController.
|
|
46
|
-
*
|
|
47
|
-
* @param {Connection} connection
|
|
48
|
-
*
|
|
49
|
-
* @memberOf BrokerController
|
|
50
|
-
*/
|
|
51
|
-
constructor(connection: Connection) {
|
|
52
|
-
super(connection);
|
|
53
|
-
this.Connections = [];
|
|
54
|
-
}
|
|
55
|
-
/**
|
|
56
|
-
*
|
|
57
|
-
*
|
|
58
|
-
*
|
|
59
|
-
* @memberOf BrokerController
|
|
60
|
-
*/
|
|
61
|
-
onopen() {
|
|
62
|
-
this.Peer = new PeerConnection(StringUtils.newGuid(), this.connection.id);
|
|
63
|
-
this.invoke(this.Peer, "contextCreated", this.alias);
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
/**
|
|
67
|
-
*
|
|
68
|
-
*
|
|
69
|
-
* @param {*} data
|
|
70
|
-
* @param {string} topic
|
|
71
|
-
* @param {string} controller
|
|
72
|
-
*
|
|
73
|
-
* @memberOf BrokerController
|
|
74
|
-
*/
|
|
75
|
-
@CanInvoke(true)
|
|
76
|
-
instantMessage(data: any, topic: string, controller: string) {
|
|
77
|
-
/**
|
|
78
|
-
*
|
|
79
|
-
*
|
|
80
|
-
* @param {BrokerController} pre
|
|
81
|
-
* @returns
|
|
82
|
-
*/
|
|
83
|
-
var expression = (pre: BrokerController) => {
|
|
84
|
-
return pre.Peer.context >= this.Peer.context;
|
|
85
|
-
};
|
|
86
|
-
this.invokeTo(expression, data, "instantMessage", this.alias);
|
|
87
|
-
}
|
|
88
|
-
/**
|
|
89
|
-
*
|
|
90
|
-
*
|
|
91
|
-
* @param {PeerConnection} change
|
|
92
|
-
*
|
|
93
|
-
* @memberOf BrokerCControllerPropertiesontroller
|
|
94
|
-
*/
|
|
95
|
-
@CanInvoke(true)
|
|
96
|
-
changeContext(change: PeerConnection) {
|
|
97
|
-
this.Peer.context = change.context;
|
|
98
|
-
this.invoke(this.Peer, "contextChanged", this.alias);
|
|
99
|
-
}
|
|
100
|
-
/**
|
|
101
|
-
*
|
|
102
|
-
*
|
|
103
|
-
* @param {Signal} signal
|
|
104
|
-
*
|
|
105
|
-
* @memberOf BrokerController
|
|
106
|
-
*/
|
|
107
|
-
@CanInvoke(true)
|
|
108
|
-
contextSignal(signal: Signal) {
|
|
109
|
-
/**
|
|
110
|
-
*
|
|
111
|
-
*
|
|
112
|
-
* @param {BrokerController} pre
|
|
113
|
-
* @returns
|
|
114
|
-
*/
|
|
115
|
-
let expression = (pre: BrokerController) => {
|
|
116
|
-
return pre.connection.id === signal.recipient;
|
|
117
|
-
};
|
|
118
|
-
this.invokeTo(expression, signal, "contextSignal", this.alias);
|
|
119
|
-
}
|
|
120
|
-
/**
|
|
121
|
-
*
|
|
122
|
-
*
|
|
123
|
-
*
|
|
124
|
-
* @memberOf BrokerController
|
|
125
|
-
*/
|
|
126
|
-
@CanInvoke(true)
|
|
127
|
-
connectContext() {
|
|
128
|
-
/**
|
|
129
|
-
*
|
|
130
|
-
*
|
|
131
|
-
* @param {BrokerController} p
|
|
132
|
-
* @returns
|
|
133
|
-
*/
|
|
134
|
-
let connections = this.getPeerConnections(this.Peer).map((p: BrokerController) => {
|
|
135
|
-
return p.Peer;
|
|
136
|
-
});
|
|
137
|
-
this.invoke(connections, "connectTo", this.alias);
|
|
138
|
-
}
|
|
139
|
-
/**
|
|
140
|
-
*
|
|
141
|
-
*
|
|
142
|
-
* @param {PeerConnection} peerConnetion
|
|
143
|
-
* @returns {Array<BrokerController>}
|
|
144
|
-
*
|
|
145
|
-
* @memberOf BrokerController
|
|
146
|
-
*/
|
|
147
|
-
getPeerConnections(peerConnetion: PeerConnection): Array<ControllerBase> {
|
|
148
|
-
let match = this.findOn<BrokerController>(this.alias, (pre: BrokerController) => {
|
|
149
|
-
return pre.Peer.context === this.Peer.context && pre.Peer.peerId !== peerConnetion.peerId;
|
|
150
|
-
});
|
|
151
|
-
return match;
|
|
152
|
-
}
|
|
153
|
-
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
require("reflect-metadata");
|
|
4
|
-
function CanInvoke(state, alias) {
|
|
5
|
-
return function (target, propertyKey, descriptor) {
|
|
6
|
-
Reflect.defineMetadata("canInvokeOrSet", state, target, propertyKey);
|
|
7
|
-
};
|
|
8
|
-
}
|
|
9
|
-
exports.CanInvoke = CanInvoke;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function CanSet(state: boolean): (target: Object, propertyKey: string) => void;
|
package/src/Decorators/CanSet.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function ControllerProperties(alias: string, seald?: boolean, heartbeatInterval?: number): (target: Function) => void;
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
function ControllerProperties(alias, seald, heartbeatInterval) {
|
|
4
|
-
return function (target) {
|
|
5
|
-
Reflect.defineMetadata("seald", seald || false, target);
|
|
6
|
-
Reflect.defineMetadata("alias", alias, target);
|
|
7
|
-
Reflect.defineMetadata("heartbeatInterval", heartbeatInterval || -1, target);
|
|
8
|
-
};
|
|
9
|
-
}
|
|
10
|
-
exports.ControllerProperties = ControllerProperties;
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
import { ITransportMessage } from "./ITransportMessage";
|
|
3
|
-
import { IInterceptor } from "./IInterceptor";
|
|
4
|
-
import { IncomingMessage } from 'http';
|
|
5
|
-
export interface ITransport {
|
|
6
|
-
id: string;
|
|
7
|
-
socket: any;
|
|
8
|
-
readyState: number;
|
|
9
|
-
send(data: any): void;
|
|
10
|
-
close(reason: number, message: any): void;
|
|
11
|
-
addEventListener(topic: string, fn: Function): void;
|
|
12
|
-
ping(): void;
|
|
13
|
-
onMessage: (message: ITransportMessage) => void;
|
|
14
|
-
onClose: (e: any) => void;
|
|
15
|
-
onOpen: (e: any) => void;
|
|
16
|
-
interceptors: Map<string, IInterceptor>;
|
|
17
|
-
request: IncomingMessage | any;
|
|
18
|
-
}
|
package/src/Listener.d.ts
DELETED