In Ditto, synchronization happens over a variety of network transports — including local peer-to-peer connections (Bluetooth, LAN, AWDL, WI-FI Aware, and Wi-Fi), as well as cloud-based sync via the Ditto Server. While Ditto handles these connections automatically by default, you may want more control over which transports are used, how they’re configured, or when they’re enabled. This guide walks you through how to customize these transport settings to suit your app’s specific connectivity and sync requirements.
DittoTransportConfig
does not enable this feature by default. Rather, you manually enable peer-to-peer connections using EnableAllPeerToPeer()
.This is only true if you provide a custom instance of the DittoTransportConfig
object. If you do not provide a custom instance, Ditto will automatically enable all peer-to-peer transports by default.The best way to ensure that you are using the correct transport configuration is to use the updateTransportConfig
API to update the DittoTransportConfig
object. This will ensure that you are using the correct transport configuration and that you are not missing any transports.DittoTransportConfig
object.
updateTransportConfig
API after
sync has been started will instantly apply the changes without the need to manually stop and start sync.websocketURL
to the DittoTransportConfig
object. You can do this by calling updateTransportConfig
and adding the websocketURL
to the connect.websocketURLs
array.
updateTransportConfig
API to remove all webSocketURLs
from the connect object will disable sync with the Ditto Server instantly without needing to call stop and start sync on the Ditto instance.