microsoft / MixedReality-WebRTC

MixedReality-WebRTC is a collection of components to help mixed reality app developers integrate audio and video real-time communication into their application and improve their collaborative experience
https://microsoft.github.io/MixedReality-WebRTC/
MIT License
913 stars 283 forks source link

Support string in DataChannel.SendMessage #673

Closed torepaulsson closed 3 years ago

torepaulsson commented 3 years ago

I've tested to implement this somewhat in this draft PR: https://github.com/microsoft/MixedReality-WebRTC/pull/675

Describe the problem I'm not 100% sure about this, but, once a DataChannel is setup there is these two methods to send raw bytes over the data channel:

SendMessage(IntPtr message, ulong size)
SendMessage(byte[] message)

The only way to send messages right now is using raw bytes, but there should be another alternative according to the RFC (https://tools.ietf.org/html/rfc8831). The RFC states that the Payload Protocol Identifier (PPID) used in the data channel can be used to indicate raw bytes or UTF8 encoded data.

It would be great to have this available in the package as well, and might not be much trouble if the underlying support in the library is already there (hopefully).

Describe the solution you'd like Overload the SendMessage method with another alternative:

DataChannel.SendMessage(string message)

This would UTF8 encode the message and send it by with the PPID flag.

Describe alternatives you've considered I see no other way to make this happen, there is no way to send the raw bytes as a UTF8 message since it is set by the underlying protocol, I think?

torepaulsson commented 3 years ago

I've checked the C++ code and found the following in data_channel.cpp image

I don't have Visual Studio 2017 (yet) and am not that familiar with C++, but it seems this boolean is what I'm looking for!

torepaulsson commented 3 years ago

Closed issue since the library now supports the flag using the SendMessageEx method and the MessageReceivedEx event.

mikhaylo1 commented 3 years ago

@torepaulsson would you mind to publish mrwebrtc.dll with that fix ? I have the same problem you described - the peer I am connecting to doesn't accept blob DataChannel messages from MixedReality-WebRTC 2.0.2 and expects text only

It looks like there is only win32-x64-Debug version published https://dev.azure.com/aipmr/MixedReality-WebRTC-CI/_build/results?buildId=19141&view=artifacts&pathAsName=false&type=publishedArtifacts

Very interested in win32-x64-Release build and failed to build it myself

torepaulsson commented 3 years ago

@mikhaylo1, I'm sorry but I'm not the owner of this repository and unsure how it is published. I've built mine locally instead, it would be great if we could get a official release though. Maybe @djee-ms can help with that, if the release pipeline still functions.

Seems like some pipeline is up and running but for the android one it fails with cleaning up the linux base image with the following error

No apt package "heroku", but there is a snap with that name.
Try "snap install heroku"
mikhaylo1 commented 3 years ago

I am looking for Win32 Release build, as far as I see there is only a Release artifact for UWP build generated with that change in DataChannels

@djee-ms Is there any chance to run the pipeline and generate artifacts for the current master repository ?