Search code examples
airconsole

How do I distinguish between reliable and unreliable messages on AirConsole


Airconsole says they use WebRTC if available. IIRC WebRTC provides both TCP and UDP options to send data.

How do I choose which one to send over using the Airconsole API? I'd expect to be able to send things like controller inputs over UDP but things like controller state changes ("switch to the name input UI") over TCP.

Also, can I detect when I have a direct WebRTC Game to Phone connection? In that case it seems like I should be able to ignore the 10 messages per second limit.


Solution

  • AirConsole is always using TCP WebRTC data channels. UDP can not be specified in our API. The WebRTC mechanism is meant as an latency improvement that is nice to have but is not guaranteed. The AirConsole API abstracts all of this for developers - WebRTC messages behave exactly like WebSocket messages or long polling messages and we apply the same restrictions for consistency (e.g. the rate limit). AirConsole messages are always guaranteed to arrive.

    You could of course still open your own UDP WebRTC connections inside your game between the phones and the screen and use the AirConsole messaging API to do the handshake. We don't recommend this, because iOS does not support WebRTC as of today and therefor the gaming experience would suffer a lot on iPhones and iPods.