File tree Expand file tree Collapse file tree 3 files changed +18
-26
lines changed
android-java/app/src/main/java/com/example/dittotasks
android-kotlin/QuickStartTasks/app/src/main/java/live/ditto/quickstart/tasks
java-spring/src/main/java/com/ditto/example/spring/quickstart/service Expand file tree Collapse file tree 3 files changed +18
-26
lines changed Original file line number Diff line number Diff line change @@ -105,13 +105,13 @@ void initDitto() {
105
105
DITTO_AUTH_URL );
106
106
ditto = new Ditto (androidDependencies , identity );
107
107
108
- // Set the Ditto Websocket URL
109
- DittoTransportConfig config = new DittoTransportConfig ();
110
- config .getConnect ().getWebsocketUrls ().add (DITTO_WEBSOCKET_URL );
108
+ ditto . updateTransportConfig ( config -> {
109
+ // Set the Ditto Websocket URL
110
+ config .getConnect ().getWebsocketUrls ().add (DITTO_WEBSOCKET_URL );
111
111
112
- // Enable all P2P transports
113
- config . enableAllPeerToPeer () ;
114
- ditto . setTransportConfig ( config );
112
+ // lambda must return Kotlin Unit which corresponds to 'void' in Java
113
+ return kotlin . Unit . INSTANCE ;
114
+ } );
115
115
116
116
// disable sync with v3 peers, required for DQL
117
117
ditto .disableSyncWithV3 ();
Original file line number Diff line number Diff line change @@ -53,14 +53,10 @@ class TasksApplication : Application() {
53
53
)
54
54
55
55
ditto = Ditto (androidDependencies, identity)
56
-
57
- // Set the Ditto Websocket URL
58
- val transportConfig = DittoTransportConfig ()
59
- transportConfig.connect.websocketUrls.add(webSocketURL)
60
-
61
- // Enable all P2P transports
62
- transportConfig.enableAllPeerToPeer()
63
- ditto.transportConfig = transportConfig
56
+ ditto.updateTransportConfig { config ->
57
+ // Set the Ditto Websocket URL
58
+ config.connect.websocketUrls.add(webSocketURL)
59
+ }
64
60
65
61
// disable sync with v3 peers, required for DQL
66
62
ditto.disableSyncWithV3()
Original file line number Diff line number Diff line change @@ -68,18 +68,14 @@ public class DittoService implements DisposableBean {
68
68
// disable sync with v3 peers, required for DQL
69
69
this .ditto .disableSyncWithV3 ();
70
70
71
- DittoTransportConfig transportConfig = new DittoTransportConfig .Builder ()
72
- .connect (connect -> {
73
- // Set the Ditto Websocket URL
74
- connect .addWebsocketUrls (DittoSecretsConfiguration .DITTO_WEBSOCKET_URL );
75
- })
76
- .build ();
77
-
78
- logger .info ("Transport config: {}" , transportConfig );
79
-
80
- this .ditto .setTransportConfig (
81
- transportConfig
82
- );
71
+ this .ditto .updateTransportConfig (config -> {
72
+ config .connect (connect -> {
73
+ // Set the Ditto Websocket URL
74
+ connect .websocketUrls ().add (DittoSecretsConfiguration .DITTO_WEBSOCKET_URL );
75
+ });
76
+
77
+ logger .info ("Transport config: {}" , config );
78
+ });
83
79
84
80
presenceObserver = observePeersPresence ();
85
81
You can’t perform that action at this time.
0 commit comments