Skip to content

.NET | Use UpdateTransportConfig to update ditto.TransportConfig #75

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 4 commits into from
Jun 10, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions dotnet-maui/DittoMauiTasksApp/MauiProgram.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,12 @@ private static Ditto SetupDitto()
PlaygroundToken,
false, // This is required to be set to false to use the correct URLs
authUrl), Path.Combine(FileSystem.Current.AppDataDirectory, "ditto"));

ditto.TransportConfig.Connect.WebsocketUrls.Add(websocketUrl);
// Optionally enable all P2P transports if using P2P Sync
// Do not call this if only using Ditto Cloud Sync
ditto.TransportConfig.Connect.WebsocketUrls.Add(websocketUrl);

ditto.UpdateTransportConfig(config =>
{
// Add the websocket URL to the transport configuration.
config.Connect.WebsocketUrls.Add(websocketUrl);
});

// disable sync with v3 peers, required for DQL
ditto.DisableSyncWithV3();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Ditto" Version="4.10.0" />
<PackageReference Include="Ditto" Version="4.11.0" />
<PackageReference Include="Terminal.Gui" Version="1.17.1" />
</ItemGroup>

Expand Down
13 changes: 6 additions & 7 deletions dotnet-tui/DittoDotNetTasksConsole/TasksPeer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,13 +73,12 @@ public TasksPeer(string appId, string playgroundToken, string authUrl, string we
authUrl);

ditto = new Ditto(identity, tempDir);

// Optionally enable all P2P transports if using P2P Sync
// Do not call this if only using Ditto Cloud Sync
ditto.TransportConfig.EnableAllPeerToPeer();

// Add the websocket URL to the transport configuration.
ditto.TransportConfig.Connect.WebsocketUrls.Add(websocketUrl);

ditto.UpdateTransportConfig(config =>
{
// Add the websocket URL to the transport configuration.
config.Connect.WebsocketUrls.Add(websocketUrl);
});

// disable sync with v3 peers, required for DQL
ditto.DisableSyncWithV3();
Expand Down
20 changes: 10 additions & 10 deletions dotnet-winforms/TasksApp/DittoTasksApp.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,36 +9,36 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Ditto" Version="4.10.2" />
<PackageReference Include="Ditto" Version="4.11.0" />
<PackageReference Include="System.Text.Json" Version="9.0.4" />
</ItemGroup>
</ItemGroup>



<ItemGroup>
<!-- See the README for instructions on creating this file, if it doesn't exist -->
<EmbeddedResource Include="../../.env">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</EmbeddedResource>
</ItemGroup>
</ItemGroup>



<ItemGroup>
<Compile Update="Properties\Resources.Designer.cs">
<DesignTime>True</DesignTime>
<AutoGen>True</AutoGen>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
</ItemGroup>
</ItemGroup>



<ItemGroup>
<EmbeddedResource Update="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
</EmbeddedResource>
</ItemGroup>
</ItemGroup>



<ItemGroup>
<None Update="assets\sync-off.bmp">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
Expand All @@ -48,4 +48,4 @@
</None>
</ItemGroup>

</Project>
</Project>
13 changes: 6 additions & 7 deletions dotnet-winforms/TasksApp/TasksPeer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,13 +70,12 @@ public TasksPeer(string appId, string playgroundToken, string authUrl, string we
authUrl);

ditto = new Ditto(identity, dir);

// Optionally enable all P2P transports if using P2P Sync
// Do not call this if only using Ditto Cloud Sync
ditto.TransportConfig.EnableAllPeerToPeer();

// Add the websocket URL to the transport configuration.
ditto.TransportConfig.Connect.WebsocketUrls.Add(websocketUrl);

ditto.UpdateTransportConfig(config =>
{
// Add the websocket URL to the transport configuration.
ditto.TransportConfig.Connect.WebsocketUrls.Add(websocketUrl);
});

// disable sync with v3 peers, required for DQL
ditto.DisableSyncWithV3();
Expand Down
Loading