feat: warn when server and client versions differ during connection setup

This commit is contained in:
Stone_Red
2026-07-23 23:06:14 +02:00
committed by HueByte
parent 07996a78ed
commit 7eced63608
4 changed files with 36 additions and 4 deletions
+15
View File
@@ -1373,6 +1373,21 @@ public sealed class AppOrchestrator : IDisposable
_mainWindow.FocusInput(); _mainWindow.FocusInput();
FetchAndUpdateOnlineUsers(); FetchAndUpdateOnlineUsers();
}); });
if (result.ServerInfo is not null && !string.IsNullOrEmpty(result.ServerInfo.Version)
&& result.ServerInfo.Version != UpdateChecker.CurrentVersion)
{
InvokeUI(() => {
var choice = MessageBox.Query(_app, "Version Mismatch",
$"Server version {result.ServerInfo.Version} does not match client version {UpdateChecker.CurrentVersion}.\n\n" +
"Some features may not work correctly. Consider updating both to the same version.",
"Continue", "Disconnect");
if (choice == 1)
HandleDisconnect();
});
}
SaveServerToConfig(dialogResult); SaveServerToConfig(dialogResult);
}, "Connection failed", "Connect"); }, "Connection failed", "Connect");
} }
@@ -15,7 +15,8 @@ namespace EchoHub.Client.Services;
internal record ConnectResult( internal record ConnectResult(
LoginResponse Login, LoginResponse Login,
List<ChannelDto> Channels, List<ChannelDto> Channels,
Dictionary<string, List<MessageDto>> Histories); Dictionary<string, List<MessageDto>> Histories,
ServerStatusDto? ServerInfo = null);
/// <summary> /// <summary>
/// Owns connection lifecycle, authentication, SignalR event wiring, and channel tracking. /// Owns connection lifecycle, authentication, SignalR event wiring, and channel tracking.
@@ -67,6 +68,17 @@ internal sealed class ConnectionManager : IAsyncDisposable
try try
{ {
onStatus("Fetching server info...");
ServerStatusDto? serverInfo = null;
try
{
serverInfo = await _apiClient.GetServerInfoAsync();
}
catch (Exception ex)
{
Log.Warning(ex, "Failed to fetch server info");
}
onStatus("Authenticating..."); onStatus("Authenticating...");
LoginResponse loginResponse; LoginResponse loginResponse;
@@ -165,7 +177,7 @@ internal sealed class ConnectionManager : IAsyncDisposable
} }
onStatus("Connected"); onStatus("Connected");
return new ConnectResult(loginResponse, channels, histories); return new ConnectResult(loginResponse, channels, histories, serverInfo);
} }
catch catch
{ {
+2 -1
View File
@@ -5,6 +5,7 @@ public record ServerStatusDto(
string? Description, string? Description,
int OnlineUsers, int OnlineUsers,
int TotalChannels, int TotalChannels,
string RegistrationMode = "open"); string RegistrationMode = "open",
string Version = "0.0.0");
public record EncryptionKeyResponse(string Key); public record EncryptionKeyResponse(string Key);
@@ -1,3 +1,4 @@
using System.Reflection;
using System.Security.Claims; using System.Security.Claims;
using EchoHub.Core.DTOs; using EchoHub.Core.DTOs;
using EchoHub.Core.Models; using EchoHub.Core.Models;
@@ -38,12 +39,15 @@ public class ServerController : ControllerBase
_ => "open", _ => "open",
}; };
var version = typeof(ServerController).Assembly.GetName().Version?.ToString(3) ?? "0.0.0";
var status = new ServerStatusDto( var status = new ServerStatusDto(
_config["Server:Name"] ?? "EchoHub Server", _config["Server:Name"] ?? "EchoHub Server",
_config["Server:Description"], _config["Server:Description"],
userCount, userCount,
channelCount, channelCount,
registrationMode); registrationMode,
version);
return Ok(status); return Ok(status);
} }