diff options
author | metamuffin <metamuffin@disroot.org> | 2022-10-13 09:11:56 +0200 |
---|---|---|
committer | metamuffin <metamuffin@disroot.org> | 2022-10-13 09:11:56 +0200 |
commit | bc8bba637e51d1c813c3edcf8747991dc69319e9 (patch) | |
tree | dba56c517f5de623ce46ec18a065cc274d8e92dc | |
parent | c8ac1b899f7a79898b3ec84157db642051e8e1ae (diff) | |
download | keks-meet-bc8bba637e51d1c813c3edcf8747991dc69319e9.tar keks-meet-bc8bba637e51d1c813c3edcf8747991dc69319e9.tar.bz2 keks-meet-bc8bba637e51d1c813c3edcf8747991dc69319e9.tar.zst |
modify client-web to not sent big messages
-rw-r--r-- | client-native-rift/src/main.rs | 3 | ||||
-rw-r--r-- | client-web/source/helper.ts | 2 | ||||
-rw-r--r-- | client-web/source/resource/file.ts | 8 | ||||
-rw-r--r-- | readme.md | 2 |
4 files changed, 11 insertions, 4 deletions
diff --git a/client-native-rift/src/main.rs b/client-native-rift/src/main.rs index 7176290..72c8396 100644 --- a/client-native-rift/src/main.rs +++ b/client-native-rift/src/main.rs @@ -89,8 +89,9 @@ impl EventHandler for Handler { info: client_native_lib::protocol::ProvideInfo, ) -> DynFut<()> { let id = info.id.clone(); + let args = self.args.clone(); Box::pin(async move { - match self.args.action { + match &args.action { Action::Send { filename } => {} Action::Receive { filename } => { if info.kind == "file" { diff --git a/client-web/source/helper.ts b/client-web/source/helper.ts index adb5f08..f53c945 100644 --- a/client-web/source/helper.ts +++ b/client-web/source/helper.ts @@ -85,4 +85,4 @@ export function notify(body: string, author?: string) { new Notification(`keks-meet`, { body }) } -export function sleep(delay: number) { return new Promise(r => setTimeout(r, delay)) }
\ No newline at end of file +export function sleep(delay: number) { return new Promise(r => setTimeout(r, delay)) } diff --git a/client-web/source/resource/file.ts b/client-web/source/resource/file.ts index 6cf3ff6..18a1ac7 100644 --- a/client-web/source/resource/file.ts +++ b/client-web/source/resource/file.ts @@ -9,6 +9,8 @@ import { ebutton, ediv, espan, sleep } from "../helper.ts"; import { log } from "../logger.ts"; import { LocalResource, ResourceHandlerDecl } from "./mod.ts"; +const MAX_CHUNK_SIZE = 1 << 15; + export const resource_file: ResourceHandlerDecl = { kind: "file", new_remote(info, user, enable) { @@ -111,11 +113,13 @@ function file_res_inner(file: File): LocalResource { return channel.close() } const feed = async () => { - const { value: chunk, done } = await reader.read() + const { value: chunk, done }: { value: Uint8Array, done: boolean } = await reader.read() if (done) return await finish() if (!chunk) console.warn("no chunk"); position += chunk.length - channel.send(chunk) + for (let i = 0; i < chunk.length; i += MAX_CHUNK_SIZE) { + channel.send(chunk.slice(i, Math.min(i + MAX_CHUNK_SIZE, chunk.length))) + } display.status = `${position} / ${file.size} (buffer: ${channel.bufferedAmount})` } const feed_until_full = async () => { @@ -104,6 +104,8 @@ system works as follows: - workaround using service worker - service worker to implement manual updates - open chat links in a new tab +- increase message size again when https://github.com/webrtc-rs/webrtc/pull/304 + is resolved ## Parameters |