Closed AndrewJudson closed 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.
Got it, thanks. Is this different than sending it ala c.publisher.handle.sendMessage({ kind: "data" })
?
Yes, it's different. There are two different transports:
c.publisher.handle.sendMessage({ kind: "data", whom: "783565908", body: "foo" })
), then it will act by pushing out an event on the websocket of the "whom" user in question containing the body you sent. This could be useful as a substitute for WebRTC data channels in applications where establishing a data channel is not easy, or where you want "private messages". The "message count" widget isn't looking at these.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.
Hey dumb question - is the reliableChannel over TCP?
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.
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.