-
Notifications
You must be signed in to change notification settings - Fork 3
refactor(java,kotlin): use updateTransportConfig lambda to configure transports #78
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -105,13 +105,12 @@ void initDitto() { | |
DITTO_AUTH_URL); | ||
ditto = new Ditto(androidDependencies, identity); | ||
|
||
// Set the Ditto Websocket URL | ||
DittoTransportConfig config = new DittoTransportConfig(); | ||
config.getConnect().getWebsocketUrls().add(DITTO_WEBSOCKET_URL); | ||
ditto.updateTransportConfig(config -> { | ||
// Set the Ditto Websocket URL | ||
config.getConnect().getWebsocketUrls().add(DITTO_WEBSOCKET_URL); | ||
|
||
// Enable all P2P transports | ||
config.enableAllPeerToPeer(); | ||
ditto.setTransportConfig(config); | ||
return null; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The lambda returns null, which may be unnecessary if updateTransportConfig does not require a return value. Consider removing the return statement or adding a comment to clarify its purpose. Copilot uses AI. Check for mistakes. Positive FeedbackNegative Feedback |
||
}); | ||
|
||
// disable sync with v3 peers, required for DQL | ||
ditto.disableSyncWithV3(); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -68,18 +68,14 @@ public class DittoService implements DisposableBean { | |
// disable sync with v3 peers, required for DQL | ||
this.ditto.disableSyncWithV3(); | ||
|
||
DittoTransportConfig transportConfig = new DittoTransportConfig.Builder() | ||
.connect(connect -> { | ||
// Set the Ditto Websocket URL | ||
connect.addWebsocketUrls(DittoSecretsConfiguration.DITTO_WEBSOCKET_URL); | ||
}) | ||
.build(); | ||
|
||
logger.info("Transport config: {}", transportConfig); | ||
|
||
this.ditto.setTransportConfig( | ||
transportConfig | ||
); | ||
this.ditto.updateTransportConfig(config -> { | ||
config.connect(connect -> { | ||
// Set the Ditto Websocket URL | ||
connect.websocketUrls().add(DittoSecretsConfiguration.DITTO_WEBSOCKET_URL); | ||
}); | ||
|
||
logger.info("Transport config: {}", config); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [nitpick] Consider adding a comment or further context on what aspects of the transport config are logged to improve the clarity and usefulness of the debug information. Copilot uses AI. Check for mistakes. Positive FeedbackNegative Feedback |
||
}); | ||
|
||
presenceObserver = observePeersPresence(); | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ensure that returning null in the lambda is required by the API design; if the lambda is expected to have a void return type, consider removing the return statement.
Copilot uses AI. Check for mistakes.