aes70 2.0.7 → 2.0.8
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/dist/AES70.es5.js
CHANGED
|
@@ -1835,7 +1835,11 @@
|
|
|
1835
1835
|
const subscriptions = [];
|
|
1836
1836
|
|
|
1837
1837
|
const cleanup = () => {
|
|
1838
|
-
subscriptions.forEach((cb) =>
|
|
1838
|
+
subscriptions.forEach((cb) => {
|
|
1839
|
+
try {
|
|
1840
|
+
cb();
|
|
1841
|
+
} catch (e) {}
|
|
1842
|
+
});
|
|
1839
1843
|
subscriptions.length = 0;
|
|
1840
1844
|
};
|
|
1841
1845
|
subscriptions.push(
|
|
@@ -28387,7 +28391,7 @@
|
|
|
28387
28391
|
}
|
|
28388
28392
|
return 2;
|
|
28389
28393
|
} catch (err) {
|
|
28390
|
-
if (!
|
|
28394
|
+
if (!(err instanceof RemoteError)) {
|
|
28391
28395
|
throw err;
|
|
28392
28396
|
}
|
|
28393
28397
|
this._supportsEV2 = false;
|
package/package.json
CHANGED
|
@@ -260,7 +260,11 @@ export class ClientConnection extends Connection {
|
|
|
260
260
|
const subscriptions = [];
|
|
261
261
|
|
|
262
262
|
const cleanup = () => {
|
|
263
|
-
subscriptions.forEach((cb) =>
|
|
263
|
+
subscriptions.forEach((cb) => {
|
|
264
|
+
try {
|
|
265
|
+
cb();
|
|
266
|
+
} catch (e) {}
|
|
267
|
+
});
|
|
264
268
|
subscriptions.length = 0;
|
|
265
269
|
};
|
|
266
270
|
subscriptions.push(
|
package/bin/server.pike
DELETED
|
@@ -1,179 +0,0 @@
|
|
|
1
|
-
#if constant(Protocols.WebSocket)
|
|
2
|
-
Protocols.WebSocket.Port http = Protocols.WebSocket.Port(http_cb, websocket_cb, 8080);
|
|
3
|
-
|
|
4
|
-
mapping(Protocols.WebSocket.Connection:Stdio.File) websocket_to_socket = ([]);
|
|
5
|
-
mapping(Protocols.WebSocket.Connection:Stdio.File) socket_to_websocket = ([]);
|
|
6
|
-
|
|
7
|
-
string HTDOCS = combine_path(dirname(__DIR__));
|
|
8
|
-
|
|
9
|
-
string file_to_mime(string name) {
|
|
10
|
-
name = (name/".")[-1];
|
|
11
|
-
switch (lower_case(name)) {
|
|
12
|
-
case "html":
|
|
13
|
-
return "text/html";
|
|
14
|
-
case "css":
|
|
15
|
-
return "text/css";
|
|
16
|
-
case "png":
|
|
17
|
-
return "image/png";
|
|
18
|
-
case "jpg":
|
|
19
|
-
return "image/jpeg";
|
|
20
|
-
case "svg":
|
|
21
|
-
return "image/svg+xml";
|
|
22
|
-
case "js":
|
|
23
|
-
return "application/x-javascript";
|
|
24
|
-
default:
|
|
25
|
-
return "application/octet-stream";
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
void http_cb(object r) {
|
|
30
|
-
string type = r->request_type;
|
|
31
|
-
|
|
32
|
-
if (type == "GET") {
|
|
33
|
-
string fname = r->not_query;
|
|
34
|
-
|
|
35
|
-
fname = Stdio.simplify_path("./" + fname);
|
|
36
|
-
|
|
37
|
-
fname = combine_path(HTDOCS, fname);
|
|
38
|
-
|
|
39
|
-
if (Stdio.is_dir(fname)) {
|
|
40
|
-
if (!has_suffix(r->not_query, "/")) {
|
|
41
|
-
r->response_and_finish(([
|
|
42
|
-
"error" : 301,
|
|
43
|
-
"extra_heads" : ([
|
|
44
|
-
"location" : r->not_query + "/",
|
|
45
|
-
]),
|
|
46
|
-
]));
|
|
47
|
-
return;
|
|
48
|
-
}
|
|
49
|
-
fname = combine_path(fname, "index.html");
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
if (Stdio.is_file(fname)) {
|
|
53
|
-
r->response_and_finish(([
|
|
54
|
-
"error" : 200,
|
|
55
|
-
"file" : Stdio.File(fname, "r"),
|
|
56
|
-
"type" : file_to_mime(fname)
|
|
57
|
-
]));
|
|
58
|
-
return;
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
r->response_and_finish(([ "error" : 404, "data" : "No such file.", "type" : "text/plain" ]));
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
class WebSocketBridge {
|
|
66
|
-
Stdio.File socket;
|
|
67
|
-
Protocols.WebSocket.Connection websocket;
|
|
68
|
-
|
|
69
|
-
string out_buf = "";
|
|
70
|
-
int(0..1) will_write = 1;
|
|
71
|
-
|
|
72
|
-
void create(Stdio.File socket, Protocols.WebSocket.Connection websocket) {
|
|
73
|
-
this_program::socket = socket;
|
|
74
|
-
this_program::websocket = websocket;
|
|
75
|
-
|
|
76
|
-
websocket->onmessage = websocket_incoming;
|
|
77
|
-
websocket->onclose = websocket_close;
|
|
78
|
-
|
|
79
|
-
socket->set_nonblocking(socket_read, socket_write, socket_close);
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
void socket_send(string data) {
|
|
83
|
-
out_buf += data;
|
|
84
|
-
|
|
85
|
-
if (!will_write) socket_write();
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
void socket_write() {
|
|
89
|
-
if (!sizeof(out_buf)) {
|
|
90
|
-
will_write = 0;
|
|
91
|
-
return;
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
int len = socket->write(out_buf);
|
|
95
|
-
|
|
96
|
-
werror("Passed %d bytes of data from websocket to socket.\n", len);
|
|
97
|
-
|
|
98
|
-
out_buf = out_buf[len..];
|
|
99
|
-
|
|
100
|
-
will_write = 1;
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
void socket_read(mixed id, string data) {
|
|
104
|
-
werror("Passed %d bytes of data from socket to websocket.\n", sizeof(data));
|
|
105
|
-
websocket->send_binary(data);
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
void websocket_incoming(Protocols.WebSocket.Frame frame) {
|
|
109
|
-
switch (frame->opcode) {
|
|
110
|
-
case Protocols.WebSocket.FRAME_BINARY:
|
|
111
|
-
socket_send(frame->data);
|
|
112
|
-
break;
|
|
113
|
-
case Protocols.WebSocket.FRAME_TEXT:
|
|
114
|
-
socket_send(string_to_utf8(frame->text));
|
|
115
|
-
break;
|
|
116
|
-
case Protocols.WebSocket.FRAME_CLOSE:
|
|
117
|
-
// ignore
|
|
118
|
-
break;
|
|
119
|
-
default:
|
|
120
|
-
werror("Unhandled WebSocket frame %O\n", frame);
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
void websocket_close() {
|
|
125
|
-
werror("WebSocket %O closed.\n", websocket);
|
|
126
|
-
websocket->onmessage = 0;
|
|
127
|
-
websocket->onclose = 0;
|
|
128
|
-
socket->set_nonblocking(0,0,0);
|
|
129
|
-
socket->close();
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
void socket_close() {
|
|
133
|
-
werror("Socket %O closed.\n", socket);
|
|
134
|
-
socket->set_nonblocking(0,0,0);
|
|
135
|
-
websocket->close();
|
|
136
|
-
websocket->onmessage = 0;
|
|
137
|
-
websocket->onclose = 0;
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
string ip;
|
|
142
|
-
int port;
|
|
143
|
-
|
|
144
|
-
void connect_cb(int(0..1) success, object request, Stdio.File socket) {
|
|
145
|
-
if (!success) {
|
|
146
|
-
werror("Failed to connect to %s:%d: %d\n", ip, port, socket->errno());
|
|
147
|
-
request->websocket_accept()->close();
|
|
148
|
-
} else {
|
|
149
|
-
werror("Successfully connected to %O\n", socket);
|
|
150
|
-
WebSocketBridge(socket, request->websocket_accept());
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
void websocket_cb(array(string) protocols, object request) {
|
|
155
|
-
Stdio.File socket = Stdio.File();
|
|
156
|
-
|
|
157
|
-
werror("Connecting new WebSocket to %s:%d\n", ip, port);
|
|
158
|
-
|
|
159
|
-
socket->async_connect(ip, port, connect_cb, request, socket);
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
int main(int argc, array(string) argv) {
|
|
163
|
-
if (argc < 3) {
|
|
164
|
-
werror("%s <ip> <port>\n", argv[0]);
|
|
165
|
-
exit(1);
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
ip = argv[1];
|
|
169
|
-
port = (int)argv[2];
|
|
170
|
-
|
|
171
|
-
werror("Forwarding WebSockets to OCA device at %s:%d\n", ip, port);
|
|
172
|
-
|
|
173
|
-
werror("Go to http://localhost:8080/\n");
|
|
174
|
-
|
|
175
|
-
return -1;
|
|
176
|
-
}
|
|
177
|
-
#else
|
|
178
|
-
#error This Program requires WebSocket support. Support for WebSockets was added in Pike version 8.
|
|
179
|
-
#endif
|