aes70 2.0.7 → 2.0.10

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) => cb());
1838
+ subscriptions.forEach((cb) => {
1839
+ try {
1840
+ cb();
1841
+ } catch (e) {}
1842
+ });
1839
1843
  subscriptions.length = 0;
1840
1844
  };
1841
1845
  subscriptions.push(
@@ -15658,14 +15662,14 @@
15658
15662
  */
15659
15663
 
15660
15664
  function OcaInterval(DT) {
15661
- return Struct(
15665
+ return class extends Struct(
15662
15666
  {
15663
15667
  Min: DT,
15664
15668
  Max: DT,
15665
15669
  Bounds: OcaIntervalBounds$1,
15666
15670
  },
15667
15671
  OcaInterval$1
15668
- );
15672
+ ) {};
15669
15673
  }
15670
15674
 
15671
15675
  /*
@@ -28387,7 +28391,7 @@
28387
28391
  }
28388
28392
  return 2;
28389
28393
  } catch (err) {
28390
- if (!RemoteError.check_status(err, OcaStatus$1.NotImplemented)) {
28394
+ if (!(err instanceof RemoteError)) {
28391
28395
  throw err;
28392
28396
  }
28393
28397
  this._supportsEV2 = false;
@@ -28828,9 +28832,13 @@
28828
28832
  options.type
28829
28833
  );
28830
28834
 
28831
- await waitForKeepalive(socket, options);
28832
-
28833
- return new this(socket, options);
28835
+ try {
28836
+ await waitForKeepalive(socket, options);
28837
+ return new this(socket, options);
28838
+ } catch (err) {
28839
+ socket.close();
28840
+ throw err;
28841
+ }
28834
28842
  }
28835
28843
 
28836
28844
  write(buf) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "aes70",
3
- "version": "2.0.7",
3
+ "version": "2.0.10",
4
4
  "description": "A controller library for the AES70 protocol.",
5
5
  "type": "module",
6
6
  "main": "src/index.js",
@@ -6,12 +6,12 @@ import { Struct } from './Struct.js';
6
6
  import { OcaInterval as type } from '../types/OcaInterval.js';
7
7
 
8
8
  export function OcaInterval(DT) {
9
- return Struct(
9
+ return class extends Struct(
10
10
  {
11
11
  Min: DT,
12
12
  Max: DT,
13
13
  Bounds: OcaIntervalBounds,
14
14
  },
15
15
  type
16
- );
16
+ ) {};
17
17
  }
@@ -103,9 +103,13 @@ export class AbstractUDPConnection extends ClientConnection {
103
103
  options.type
104
104
  );
105
105
 
106
- await waitForKeepalive(socket, options);
107
-
108
- return new this(socket, options);
106
+ try {
107
+ await waitForKeepalive(socket, options);
108
+ return new this(socket, options);
109
+ } catch (err) {
110
+ socket.close();
111
+ throw err;
112
+ }
109
113
  }
110
114
 
111
115
  write(buf) {
@@ -260,7 +260,11 @@ export class ClientConnection extends Connection {
260
260
  const subscriptions = [];
261
261
 
262
262
  const cleanup = () => {
263
- subscriptions.forEach((cb) => cb());
263
+ subscriptions.forEach((cb) => {
264
+ try {
265
+ cb();
266
+ } catch (e) {}
267
+ });
264
268
  subscriptions.length = 0;
265
269
  };
266
270
  subscriptions.push(
@@ -242,7 +242,7 @@ export class RemoteDevice extends Events {
242
242
  }
243
243
  return 2;
244
244
  } catch (err) {
245
- if (!RemoteError.check_status(err, OcaStatus.NotImplemented)) {
245
+ if (!(err instanceof RemoteError)) {
246
246
  throw err;
247
247
  }
248
248
  this._supportsEV2 = false;
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
@@ -1,18 +0,0 @@
1
- /*
2
- * This file has been generated.
3
- */
4
- import { OcaBlobFixedLen } from './OcaBlobFixedLen.js';
5
- import { OcaUint16 } from './OcaUint16.js';
6
- import { OcaUint8 } from './OcaUint8.js';
7
- import { Struct } from './Struct.js';
8
-
9
- import { OcaClassAuthorityID as type } from '../types/OcaClassAuthorityID.js';
10
-
11
- export const OcaClassAuthorityID = Struct(
12
- {
13
- Sentinel: OcaUint16,
14
- Reserved: OcaUint8,
15
- OrganizationID: OcaBlobFixedLen(3),
16
- },
17
- type
18
- );
@@ -1,14 +0,0 @@
1
- /*
2
- * This file has been generated.
3
- */
4
- import { Struct } from './Struct.js';
5
- import { OcaUint8 } from './OcaUint8.js';
6
-
7
- import { OcaEnumItem as type } from '../types/OcaEnumItem.js';
8
-
9
- export const OcaEnumItem = Struct(
10
- {
11
- Value: OcaUint8,
12
- },
13
- type
14
- );
@@ -1,14 +0,0 @@
1
- /*
2
- * This file has been generated.
3
- */
4
- import { Struct } from './Struct.js';
5
- import { OcaUint16 } from './OcaUint16.js';
6
-
7
- import { OcaEnumItem16 as type } from '../types/OcaEnumItem16.js';
8
-
9
- export const OcaEnumItem16 = Struct(
10
- {
11
- Value: OcaUint16,
12
- },
13
- type
14
- );
@@ -1,16 +0,0 @@
1
- /*
2
- * This file has been generated.
3
- */
4
- import { OcaLibVolIdentifier } from './OcaLibVolIdentifier.js';
5
- import { OcaUint32 } from './OcaUint32.js';
6
- import { Struct } from './Struct.js';
7
-
8
- import { OcaLibParamSetAssignment as type } from '../types/OcaLibParamSetAssignment.js';
9
-
10
- export const OcaLibParamSetAssignment = Struct(
11
- {
12
- ParamSetIdentifier: OcaLibVolIdentifier,
13
- TargetBlockONo: OcaUint32,
14
- },
15
- type
16
- );
@@ -1,16 +0,0 @@
1
- /*
2
- * This file has been generated.
3
- */
4
- import { OcaBlob } from './OcaBlob.js';
5
- import { OcaLibVolMetadata } from './OcaLibVolMetadata.js';
6
- import { Struct } from './Struct.js';
7
-
8
- import { OcaLibVol as type } from '../types/OcaLibVol.js';
9
-
10
- export const OcaLibVol = Struct(
11
- {
12
- Metadata: OcaLibVolMetadata,
13
- Data: OcaBlob,
14
- },
15
- type
16
- );
@@ -1,16 +0,0 @@
1
- /*
2
- * This file has been generated.
3
- */
4
- import { OcaPropertyChangeType } from './OcaPropertyChangeType.js';
5
- import { OcaUint32 } from './OcaUint32.js';
6
- import { Struct } from './Struct.js';
7
-
8
- import { OcaLibVolChangedEventData as type } from '../types/OcaLibVolChangedEventData.js';
9
-
10
- export const OcaLibVolChangedEventData = Struct(
11
- {
12
- VolumeID: OcaUint32,
13
- ChangeType: OcaPropertyChangeType,
14
- },
15
- type
16
- );
@@ -1,23 +0,0 @@
1
- /*
2
- * This file has been generated.
3
- */
4
- import { OcaLibAccess } from './OcaLibAccess.js';
5
- import { OcaLibVolType } from './OcaLibVolType.js';
6
- import { OcaString } from './OcaString.js';
7
- import { OcaTimePTP } from './OcaTimePTP.js';
8
- import { OcaUint32 } from './OcaUint32.js';
9
- import { Struct } from './Struct.js';
10
-
11
- import { OcaLibVolMetadata as type } from '../types/OcaLibVolMetadata.js';
12
-
13
- export const OcaLibVolMetadata = Struct(
14
- {
15
- Name: OcaString,
16
- VolType: OcaLibVolType,
17
- Access: OcaLibAccess,
18
- Version: OcaUint32,
19
- Creator: OcaString,
20
- UpDate: OcaTimePTP,
21
- },
22
- type
23
- );
@@ -1,14 +0,0 @@
1
- /*
2
- * This file has been generated.
3
- */
4
- import { OcaMediaConnectorStatus } from './OcaMediaConnectorStatus.js';
5
- import { Struct } from './Struct.js';
6
-
7
- import { OcaMediaConnectorStatusChangedEventData as type } from '../types/OcaMediaConnectorStatusChangedEventData.js';
8
-
9
- export const OcaMediaConnectorStatusChangedEventData = Struct(
10
- {
11
- ConnectorStatus: OcaMediaConnectorStatus,
12
- },
13
- type
14
- );
@@ -1,15 +0,0 @@
1
- /*
2
- * This file has been generated.
3
- */
4
- import { OcaBlob } from './OcaBlob.js';
5
- import { Struct } from './Struct.js';
6
-
7
- import { OcaNetworkSystemInterfaceDescriptor as type } from '../types/OcaNetworkSystemInterfaceDescriptor.js';
8
-
9
- export const OcaNetworkSystemInterfaceDescriptor = Struct(
10
- {
11
- SystemInterfaceParameters: OcaBlob,
12
- MyNetworkAddress: OcaBlob,
13
- },
14
- type
15
- );
@@ -1,18 +0,0 @@
1
- /*
2
- * This file has been generated.
3
- */
4
- import { OcaDBr } from './OcaDBr.js';
5
- import { OcaFloat32 } from './OcaFloat32.js';
6
- import { OcaUint32 } from './OcaUint32.js';
7
- import { Struct } from './Struct.js';
8
-
9
- import { OcaPilotToneDetectorSpec as type } from '../types/OcaPilotToneDetectorSpec.js';
10
-
11
- export const OcaPilotToneDetectorSpec = Struct(
12
- {
13
- Threshold: OcaDBr,
14
- Frequency: OcaFloat32,
15
- PollInterval: OcaUint32,
16
- },
17
- type
18
- );
@@ -1,16 +0,0 @@
1
- /*
2
- * This file has been generated.
3
- */
4
- import { OcaPortMode } from './OcaPortMode.js';
5
- import { OcaUint16 } from './OcaUint16.js';
6
- import { Struct } from './Struct.js';
7
-
8
- import { OcaProtoPortID as type } from '../types/OcaProtoPortID.js';
9
-
10
- export const OcaProtoPortID = Struct(
11
- {
12
- Mode: OcaPortMode,
13
- Index: OcaUint16,
14
- },
15
- type
16
- );
@@ -1,18 +0,0 @@
1
- /*
2
- * This file has been generated.
3
- */
4
- import { OcaLibVolIdentifier } from './OcaLibVolIdentifier.js';
5
- import { OcaTaskStatus } from './OcaTaskStatus.js';
6
- import { OcaUint32 } from './OcaUint32.js';
7
- import { Struct } from './Struct.js';
8
-
9
- import { OcaTaskStateChangedEventData as type } from '../types/OcaTaskStateChangedEventData.js';
10
-
11
- export const OcaTaskStateChangedEventData = Struct(
12
- {
13
- TaskID: OcaUint32,
14
- ProgramID: OcaLibVolIdentifier,
15
- Status: OcaTaskStatus,
16
- },
17
- type
18
- );