Skip to content
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
16 changes: 13 additions & 3 deletions src/RemoteViewer.Server/Orleans/Grains/ConnectionGrain.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System.Diagnostics.CodeAnalysis;
using System.Diagnostics.CodeAnalysis;
using Microsoft.AspNetCore.SignalR;
using RemoteViewer.Server.Hubs;
using RemoteViewer.Shared;
Expand Down Expand Up @@ -28,7 +28,9 @@ public sealed partial class ConnectionGrain(ILogger<ConnectionGrain> logger, IHu

public async Task UpdateProperties(string signalrConnectionId, ConnectionProperties properties)
{
if (this._presenter?.GetPrimaryKeyString() != signalrConnectionId)
this.EnsureInitialized();

if (this._presenter.GetPrimaryKeyString() != signalrConnectionId)
{
this.LogNonPresenterUpdateAttempt(signalrConnectionId, this.GetPrimaryKeyString());
return;
Expand Down Expand Up @@ -149,6 +151,8 @@ await hubContext.Clients
}
async Task IConnectionGrain.Internal_AddViewer(IClientGrain viewer)
{
this.EnsureInitialized();

if (this._viewers.Contains(viewer))
{
this.LogViewerAlreadyInConnection(this.GetPrimaryKeyString(), viewer.GetPrimaryKeyString());
Expand Down Expand Up @@ -190,11 +194,17 @@ async Task IConnectionGrain.Internal_RemoveClient(IClientGrain client)

await hubContext.Clients.Client(client.GetPrimaryKeyString()).ConnectionStopped(this.GetPrimaryKeyString());

await this.NotifyConnectionChangedAsync();
// Only notify if presenter still exists - during teardown the presenter may have already
// disconnected and nullified _presenter, so we skip notification since the connection is dead
if (this._presenter is not null)
{
await this.NotifyConnectionChangedAsync();
}
}
}
async Task IConnectionGrain.Internal_DisplayNameChanged()
{
this.EnsureInitialized();
await this.NotifyConnectionChangedAsync();
}

Expand Down
5 changes: 1 addition & 4 deletions src/RemoteViewer.Server/Program.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Nerdbank.MessagePack.SignalR;
using Nerdbank.MessagePack.SignalR;
using RemoteViewer.Server.Hubs;
using RemoteViewer.Server.Services;
using RemoteViewer.Shared;
Expand Down Expand Up @@ -26,9 +26,6 @@
.AddSignalR(options =>
{
options.MaximumReceiveMessageSize = null;

options.ClientTimeoutInterval = TimeSpan.FromMinutes(2);
options.KeepAliveInterval = TimeSpan.FromSeconds(30);
})
.AddMessagePackProtocol(Witness.GeneratedTypeShapeProvider);
builder.Services.AddSerilog();
Expand Down