-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Change datachannel message type identifier from a string to an enum, and remove it altogether from the send method and message listener. #88
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
Conversation
…should be faster than string comparisons, so this will likely improve performance.
@FrobtheBuilder @rostopira @Codeusa
For these we can refer to WebRTC native: Another change is that the base64 type I think can be removed, because base64 is essentially a string, just encode before the transfer, decode it after receiving it, now we have the binary type, base64 is unnecessary. |
It does seem redundant to put the message type on the interface itself. So long as the type is set via a map internally on the DataBuffer/RTCDataChannelMessage it should be efficient. String comparisons are indeed slow though so the idea of this change is good. The usefulness of the base64 type IMO is that data channels do support arbitrary strings, and base64 is a work around for the binary data on Android for now. So there needs to be a way to tell the two apart until the Android side is brought to spec and just has binary data and normal strings. |
@Codeusa and @cloudwebrtc, I normalized the API between Android and iOS to encode and decode transparently already. That was in the last PR. But yes, it would be possible to just determine which type of message is being sent from the message itself. Would you rather I reconfigure it to do it that way instead? |
Also, the reason I have those base64 constructors and properties on |
…ssage handler. You can determine what kind of message is being sent and received from the RTCDataChannelMessage's type.
I just went ahead and made the change. |
Change datachannel message type identifier from a string to an enum, and remove it altogether from the send method and message listener.
Co-authored-by: alexlapa <lapa.alex@ex.ua> Co-authored-by: Kai Ren <tyranron@gmail.com>
Map lookups should be faster than string comparisons, so this will likely improve performance.
This will change the API (again) but it will also make it safer, since the compiler will notify you if you mistype the identifier as an enum.
I also did some slight reformatting elsewhere in the file.