| 1082 | } |
| 1083 | |
| 1084 | function onMessage(event: WebSocketEvent) { |
| 1085 | const data = event.data as Uint8Array | ArrayBuffer | Blob | string |
| 1086 | if (typeof Blob !== "undefined" && data instanceof Blob) { |
| 1087 | data.arrayBuffer().then((buf) => push(new Uint8Array(buf)), (cause) => { |
| 1088 | fail(new SocketError({ reason: new SocketReadError({ cause }) })) |
| 1089 | }) |
| 1090 | return |
| 1091 | } |
| 1092 | push(data instanceof ArrayBuffer ? new Uint8Array(data) : data as Uint8Array | string) |
| 1093 | } |
| 1094 | function onError(event: WebSocketEvent) { |
| 1095 | fail( |
| 1096 | new SocketError({ |