Skip to content

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

Merged
merged 3 commits into from
Jun 2, 2025

Conversation

phatblat
Copy link
Member

@phatblat phatblat commented May 27, 2025

Updated the Java and Kotlin Quickstart apps to use the ditto.updateTransportConfig() API to configure transports.

@phatblat phatblat self-assigned this May 27, 2025
@phatblat phatblat changed the title build(deps): use Ditto 4.11.0-preview.4 in .NET apps refactor: use updateTransportConfig closure/lambda to configure transports May 27, 2025
@phatblat phatblat requested review from Copilot, konstantinbe, busec0 and anyercastillo and removed request for a team, konstantinbe, anyercastillo and busec0 May 27, 2025 15:49
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR refactors the Quickstart apps in Swift, Java, Kotlin, and C# to use the new ditto.updateTransportConfig() API for configuring transports.

  • Replaces direct transport configuration assignments with closure/lambda-based configuration
  • Updates package references to the new Ditto version for .NET/C# and other platforms
  • Standardizes transport configuration syntax across multiple language implementations

Reviewed Changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
swift/tasks/tasks/DittoManager.swift Converted to use updateTransportConfig closure for Swift transport configuration
java-spring/src/main/java/com/ditto/example/spring/quickstart/service/DittoService.java Refactored transport configuration to use a lambda syntax
dotnet-winforms/TasksApp/TasksPeer.cs Updated transport configuration using a lambda in Windows Forms app
dotnet-winforms/TasksApp/DittoTasksApp.csproj Updated Ditto package version to a new preview release
dotnet-tui/DittoDotNetTasksConsole/TasksPeer.cs Refactored to use lambda for transport configuration
dotnet-tui/DittoDotNetTasksConsole/DittoDotNetTasksConsole.csproj Updated Ditto package version to a new preview release
dotnet-maui/DittoMauiTasksApp/MauiProgram.cs Updated Maui app to employ the new transport configuration lambda
dotnet-maui/DittoMauiTasksApp/DittoMauiTasksApp.csproj Updated Ditto package reference to match new version
android-kotlin/QuickStartTasks/app/src/main/java/live/ditto/quickstart/tasks/TasksApplication.kt Migrated transport configuration to lambda style in Kotlin app
android-java/app/src/main/java/com/example/dittotasks/MainActivity.java Refactored Java transport configuration to use a lambda with a return statement

// Enable all P2P transports
config.enableAllPeerToPeer();

return null;
Copy link
Preview

Copilot AI May 27, 2025

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.

@phatblat
Copy link
Member Author

Rust quickstart build is failing with a dup symbol linker error

  = note: /usr/bin/ld: /home/runner/work/quickstart/quickstart/rust-tui/target/debug/build/dittolive-ditto-sys-0c4bf004c07634a9/out/libdittoffi.a(dittoffi.b6n0uluj20jy6wl8jw3v467ec.rcgu.o):(.bss.__rust_no_alloc_shim_is_unstable+0x0): multiple definition of `__rust_no_alloc_shim_is_unstable'; /home/runner/work/quickstart/quickstart/rust-tui/target/debug/deps/ditto_quickstart-576ab587da7fd8e3.e7fl8m6u5tcgaf8tt7iegvic7.rcgu.o:(.bss.__rust_no_alloc_shim_is_unstable+0x0): first defined here

Copy link
Contributor

@busec0 busec0 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Contributor

@busec0 busec0 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missed the dotnet changes 🤦 . We already have a PR for those. #75 Same for Swift.

@phatblat phatblat force-pushed the ben/updatetransportconfig branch from 3929c87 to ed008a4 Compare May 27, 2025 16:06
…ports

refactor: use updateTransportConfig closure/lambda to configure transports
@phatblat phatblat force-pushed the ben/updatetransportconfig branch from ed008a4 to 312a7f7 Compare May 27, 2025 16:06
@phatblat phatblat changed the title refactor: use updateTransportConfig closure/lambda to configure transports refactor(java,kotlin): use updateTransportConfig closure/lambda to configure transports May 27, 2025
@phatblat
Copy link
Member Author

PR updated to just modify java & kotlin apps. .NET changes are in #74

@phatblat phatblat requested review from busec0 and Copilot May 27, 2025 16:19
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR refactors the configuration of transports in the Java and Kotlin quickstart apps by switching from manual transport configuration to the updateTransportConfig lambda/closure API. This change streamlines the transport configuration process in the Java Spring, Android Kotlin, and Android Java projects.

  • Updated Java Spring service to configure transports using a lambda.
  • Simplified Android Kotlin configuration by removing the manual transport configuration.
  • Refactored Android Java configuration to use a lambda, with an explicit return.

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
java-spring/src/main/java/com/ditto/example/spring/quickstart/service/DittoService.java Replaced manual config builder with updateTransportConfig lambda and updated logging.
android-kotlin/QuickStartTasks/app/src/main/java/live/ditto/quickstart/tasks/TasksApplication.kt Simplified transport config by using a lambda; removed explicit enabling of all P2P transports.
android-java/app/src/main/java/com/example/dittotasks/MainActivity.java Converted transport config to use a lambda with an explicit return.
Comments suppressed due to low confidence (1)

android-kotlin/QuickStartTasks/app/src/main/java/live/ditto/quickstart/tasks/TasksApplication.kt:56

  • The explicit call to enable all peer-to-peer transports was removed in this diff. Please confirm that updateTransportConfig now handles enabling P2P transports as intended, or add the necessary configuration if it is still required.
ditto.updateTransportConfig { config ->

// Enable all P2P transports
config.enableAllPeerToPeer();
ditto.setTransportConfig(config);
return null;
Copy link
Preview

Copilot AI May 27, 2025

Choose a reason for hiding this comment

The 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.

connect.websocketUrls().add(DittoSecretsConfiguration.DITTO_WEBSOCKET_URL);
});

logger.info("Transport config: {}", config);
Copy link
Preview

Copilot AI May 27, 2025

Choose a reason for hiding this comment

The 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.

@phatblat phatblat changed the title refactor(java,kotlin): use updateTransportConfig closure/lambda to configure transports refactor(java,kotlin): use updateTransportConfig lambda to configure transports May 28, 2025
@phatblat phatblat merged commit f504e45 into main Jun 2, 2025
4 of 5 checks passed
@phatblat phatblat deleted the ben/updatetransportconfig branch June 2, 2025 19:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants