From ecf846aa7a3fac98d37a7c3998c3ced82a792a3e Mon Sep 17 00:00:00 2001 From: Mike Grabowski Date: Wed, 6 Nov 2024 17:24:07 +0400 Subject: [PATCH 1/2] feat --- README.md | 1 + packages/react-native-fast-ws/src/index.ts | 11 +++++++---- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 5968b46..f9a44d4 100644 --- a/README.md +++ b/README.md @@ -53,6 +53,7 @@ ws.addEventListener('message', (event) => { // Send different types of data ws.send('Plain text message'); +ws.send(new Blob('string')); ws.send(new Uint8Array([1, 2, 3, 4])); // Close the connection when done diff --git a/packages/react-native-fast-ws/src/index.ts b/packages/react-native-fast-ws/src/index.ts index 353a33d..b3b974e 100644 --- a/packages/react-native-fast-ws/src/index.ts +++ b/packages/react-native-fast-ws/src/index.ts @@ -168,10 +168,13 @@ export class WebSocket return } - // tbd: Blob support - // if (message instanceof Blob) { - // return - // } + if (message instanceof Blob) { + ;(async () => { + const arrayBuffer = await message.arrayBuffer() + this.ws.sendArrayBuffer(arrayBuffer) + })() + return + } throw new TypeError('Invalid message type') } From 2ff83047e8951d828cb7f482f974723d476921af Mon Sep 17 00:00:00 2001 From: Mike Grabowski Date: Wed, 6 Nov 2024 17:31:32 +0400 Subject: [PATCH 2/2] revert accidential changes --- example/ios/Podfile.lock | 4 ++-- packages/react-native-fast-ws/src/spec.nitro.ts | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/example/ios/Podfile.lock b/example/ios/Podfile.lock index c87c592..817e02d 100644 --- a/example/ios/Podfile.lock +++ b/example/ios/Podfile.lock @@ -1,7 +1,7 @@ PODS: - boost (1.84.0) - DoubleConversion (1.1.6) - - FastWebSocket (0.0.1): + - FastWebSocket (0.1.1): - DoubleConversion - glog - hermes-engine @@ -1764,7 +1764,7 @@ EXTERNAL SOURCES: SPEC CHECKSUMS: boost: 1dca942403ed9342f98334bf4c3621f011aa7946 DoubleConversion: f16ae600a246532c4020132d54af21d0ddb2a385 - FastWebSocket: f7efa0908137535badb0fae69aedc6739fa6c0b7 + FastWebSocket: 3e0362e21dd65bd5bca85b7ce6efd7ab03cf1749 FBLazyVector: aa59bef5c46e93168bffcf3dc37ee1e176de799a fmt: 10c6e61f4be25dc963c36bd73fc7b1705fe975be glog: 08b301085f15bcbb6ff8632a8ebaf239aae04e6a diff --git a/packages/react-native-fast-ws/src/spec.nitro.ts b/packages/react-native-fast-ws/src/spec.nitro.ts index f23f274..ead3e43 100644 --- a/packages/react-native-fast-ws/src/spec.nitro.ts +++ b/packages/react-native-fast-ws/src/spec.nitro.ts @@ -5,7 +5,7 @@ export interface WebSocket extends HybridObject<{ ios: 'swift'; android: 'kotlin sendArrayBuffer(buffer: ArrayBuffer): void connect(): void - close(code?: number, reason?: string): void + close(code: number, reason: string): void ping(): void onOpen(callback: (selectedProtocol: string) => void): void