mirror of
https://github.com/RedWizardsLab/EchoHub.git
synced 2026-09-04 08:36:11 +02:00
feat: warn when server and client versions differ during connection setup
This commit is contained in:
@@ -1373,6 +1373,21 @@ public sealed class AppOrchestrator : IDisposable
|
||||
_mainWindow.FocusInput();
|
||||
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);
|
||||
}, "Connection failed", "Connect");
|
||||
}
|
||||
|
||||
@@ -15,7 +15,8 @@ namespace EchoHub.Client.Services;
|
||||
internal record ConnectResult(
|
||||
LoginResponse Login,
|
||||
List<ChannelDto> Channels,
|
||||
Dictionary<string, List<MessageDto>> Histories);
|
||||
Dictionary<string, List<MessageDto>> Histories,
|
||||
ServerStatusDto? ServerInfo = null);
|
||||
|
||||
/// <summary>
|
||||
/// Owns connection lifecycle, authentication, SignalR event wiring, and channel tracking.
|
||||
@@ -67,6 +68,17 @@ internal sealed class ConnectionManager : IAsyncDisposable
|
||||
|
||||
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...");
|
||||
|
||||
LoginResponse loginResponse;
|
||||
@@ -165,7 +177,7 @@ internal sealed class ConnectionManager : IAsyncDisposable
|
||||
}
|
||||
|
||||
onStatus("Connected");
|
||||
return new ConnectResult(loginResponse, channels, histories);
|
||||
return new ConnectResult(loginResponse, channels, histories, serverInfo);
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
||||
@@ -5,6 +5,7 @@ public record ServerStatusDto(
|
||||
string? Description,
|
||||
int OnlineUsers,
|
||||
int TotalChannels,
|
||||
string RegistrationMode = "open");
|
||||
string RegistrationMode = "open",
|
||||
string Version = "0.0.0");
|
||||
|
||||
public record EncryptionKeyResponse(string Key);
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
using System.Reflection;
|
||||
using System.Security.Claims;
|
||||
using EchoHub.Core.DTOs;
|
||||
using EchoHub.Core.Models;
|
||||
@@ -38,12 +39,15 @@ public class ServerController : ControllerBase
|
||||
_ => "open",
|
||||
};
|
||||
|
||||
var version = typeof(ServerController).Assembly.GetName().Version?.ToString(3) ?? "0.0.0";
|
||||
|
||||
var status = new ServerStatusDto(
|
||||
_config["Server:Name"] ?? "EchoHub Server",
|
||||
_config["Server:Description"],
|
||||
userCount,
|
||||
channelCount,
|
||||
registrationMode);
|
||||
registrationMode,
|
||||
version);
|
||||
|
||||
return Ok(status);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user