mozilla / janus-plugin-sfu

Janus plugin to act as a kind of SFU for game networking data.
Mozilla Public License 2.0
135 stars 40 forks source link

How do you send a message such that the "Data messages: Message count" counter increases in the test client? #47

Closed AndrewJudson closed 4 years ago

AndrewJudson commented 4 years ago

It isn't clear to me how to do this when testing functionality - I can send data messages between clients but it doesn't seem to get handled by the reliable or unreliable channel. Thus I am not sure what the purpose of that part of the test client is and if it is possible to interact with it.

mqp commented 4 years ago

Sorry, this was kind of left in a hacky state! In the test client if you try this in the browser REPL:

c.publisher.reliableChannel.send('{"foo": 1}')

Then other clients should see the data message come in and increment the counter. They try to deserialize it as JSON, so if it doesn't look like JSON they won't bump it.

Happy to accept PRs if you want to make the test client easier to test with. It's obviously not ideal. I'll probably at least add a button to send a message and a display that shows the last message received, which seems like the minimal sort of civilized thing.

AndrewJudson commented 4 years ago

Got it, thanks. Is this different than sending it ala c.publisher.handle.sendMessage({ kind: "data" })?

mqp commented 4 years ago

Yes, it's different. There are two different transports:

Thanks for illustrating that the test client "messages" terminology is ambiguous in this way -- it would be better for it to say "data channel packets received". Perhaps the plugin "data" message would also be better renamed, but I'm not sure to what.

AndrewJudson commented 4 years ago

Hey dumb question - is the reliableChannel over TCP?

mqp commented 4 years ago

Nope, all data channels are over SCTP. The properties of the SCTP connection are configured in the client when the channel is created and added to the RTCPeerConnection. In this case, reliableChannel is named reliable because I set ordered: true and I didn't set maxRetransmits: 0, which mean that it acts like TCP in terms of retrying on failure and ensuring order.

Note that this doesn't necessarily mean that data channel messages will make it to the other users in the room or fail, because even if both channels from the SFU are reliable, there's a missing piece -- if a data channel message makes it to the SFU but then is undeliverable to another user, there isn't currently a mechanism for the SFU to communicate back to the sender that the message wasn't delivered. Someone would need to build that to get end-to-end reliability.