Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Data channel messages slicing #82

Merged
merged 9 commits into from
Feb 1, 2020
Merged

Data channel messages slicing #82

merged 9 commits into from
Feb 1, 2020

Conversation

vvmnnnkv
Copy link
Member

This PR implements data chunking, issue #78
Data is sent as ArrayBuffer, with small header containing message id, number of chunks and chunk number. On receiver side, chunks are stitched together.

There're number of constants that control sending process:

export const WEBRTC_DATACHANNEL_CHUNK_SIZE = 64 * 1024;
export const WEBRTC_DATACHANNEL_MAX_BUFFER = 4 * 1024 * 1024;
export const WEBRTC_DATACHANNEL_BUFFER_TIMEOUT = 2000;
export const WEBRTC_DATACHANNEL_MAX_BUFFER_TIMEOUTS = 5;

Outgoing buffer is where data is buffered after channel.send() but before it is actually sent. When buffer fills up to WEBRTC_DATACHANNEL_MAX_BUFFER, we stop sending and wait for lowbuffer event from the data channel. If event doesn't occur within WEBRTC_DATACHANNEL_BUFFER_TIMEOUT, we re-try checking current buffer size. If the buffer is still larger than WEBRTC_DATACHANNEL_MAX_BUFFER after checking for WEBRTC_DATACHANNEL_MAX_BUFFER_TIMEOUTS times, we consider this to be send error.

I've tested sending 150MB between FF and Chrome located on different remote machines connected via public internet.

@codecov
Copy link

codecov bot commented Jan 31, 2020

Codecov Report

Merging #82 into master will not change coverage.
The diff coverage is 90.9%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master      #82   +/-   ##
=======================================
  Coverage   77.16%   77.16%           
=======================================
  Files          20       20           
  Lines         635      635           
  Branches       73       73           
=======================================
  Hits          490      490           
  Misses        116      116           
  Partials       29       29
Impacted Files Coverage Δ
src/_constants.js 100% <ø> (ø) ⬆️
src/data_channel_message_queue.js 100% <ø> (ø)
src/data_channel_message.js 100% <100%> (ø)
src/webrtc.js 85.33% <75%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 762dc52...5e53a2b. Read the comment docs.

Copy link
Member

@cereallarceny cereallarceny left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is perfect. I only request that you look at changing the class names to avoid conflicts or confusion.

src/message.js Outdated Show resolved Hide resolved
src/message_queue.js Outdated Show resolved Hide resolved
Copy link
Member

@cereallarceny cereallarceny left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@cereallarceny cereallarceny merged commit 185c724 into master Feb 1, 2020
@cereallarceny cereallarceny deleted the vvm/data-messages branch February 1, 2020 10:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants