feat: Notification based BufferedDataConnection #1143
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I have the use case of Datachannel of trying to send files from one client to the other. The speed is not particularly an issue anymore but I would still like to have Notifications/events for when a chunk is complete to create Progress Bars.
This PR addresses that. If connecting with the serialization 'notify', the Dataconnection will emit an additional event for when a chunk is done sending. The user can subscribe to this and use the information as they please. An example of this is:
I also have some ideas on what to do for the other Stream based serializations so I have kept the events in the base
DataConnection
without implementing these events. ButBufferedDataConnection
has got me covered nicely so far :)I was thinking of adding a callback based api but favoured the event driven approach since I found it aligned well with what you guys were doing already.
Haven't made tests since I couldn't get them to work on my machine but I tried it with a personal example extensively, can give more examples if necessary, some of which reside in my continuation of #1075.
Thank you for your work and I hope this is useful to somebody as well