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
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ private void AuthenticationStateChanged(Task<AuthenticationState> task)
//#if (signalR == true)
private void SubscribeToSignalREventsMessages()
{
signalROnDisposables.Add(hubConnection.On<string, object, bool>(SignalREvents.SHOW_MESSAGE, async (message, data) =>
signalROnDisposables.Add(hubConnection.On<string, Dictionary<string, string?>?, bool>(SignalREvents.SHOW_MESSAGE, async (message, data) =>
{
logger.LogInformation("SignalR Message {Message} received from server to show.", message);
if (await notification.IsNotificationAvailable())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ private async Task PublishUserProfileUpdated(User user, CancellationToken cancel
.Where(us => us.UserId == user.Id && us.Id != currentUserSessionId && us.SignalRConnectionId != null)
.Select(us => us.SignalRConnectionId!)
.ToArrayAsync(cancellationToken);
await appHubContext.Clients.Clients(userSessionIdsExceptCurrentUserSessionId).SendAsync(SignalREvents.PUBLISH_MESSAGE, SharedPubSubMessages.PROFILE_UPDATED, user, cancellationToken);
await appHubContext.Clients.Clients(userSessionIdsExceptCurrentUserSessionId).SendAsync(SignalREvents.PUBLISH_MESSAGE, SharedPubSubMessages.PROFILE_UPDATED, user.Map(), cancellationToken);
}
//#endif

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public async Task<string> PerformDiagnostics([FromQuery] string? signalRConnecti
//#if (signalR == true)
if (string.IsNullOrEmpty(signalRConnectionId) is false)
{
var success = await appHubContext.Clients.Client(signalRConnectionId).InvokeAsync<bool>(SignalREvents.SHOW_MESSAGE, $"Open terms page. {DateTimeOffset.Now:HH:mm:ss}", new { pageUrl = PageUrls.Terms, action = "testAction" }, cancellationToken);
var success = await appHubContext.Clients.Client(signalRConnectionId).InvokeAsync<bool>(SignalREvents.SHOW_MESSAGE, $"Open terms page. {DateTimeOffset.Now:HH:mm:ss}", new Dictionary<string, string?> { { "pageUrl", PageUrls.Terms }, { "action", "testAction" } }, cancellationToken);
if (success is false) // Client would return false if it's unable to show the message with custom action.
{
await appHubContext.Clients.Client(signalRConnectionId).SendAsync(SignalREvents.SHOW_MESSAGE, $"Simple message. {DateTimeOffset.Now:HH:mm:ss}", null, cancellationToken);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -227,14 +227,14 @@ public async Task SendNotification(SendNotificationToRoleDto dto, CancellationTo
.Select(us => us.SignalRConnectionId!).ToArrayAsync(cancellationToken);

await appHubContext.Clients.Clients(signalRConnectionIds)
.SendAsync(SignalREvents.SHOW_MESSAGE, dto.Message, dto.PageUrl is null ? null : new { pageUrl = dto.PageUrl }, cancellationToken);
.SendAsync(SignalREvents.SHOW_MESSAGE, dto.Message, dto.PageUrl is null ? null : new Dictionary<string, string?> { { "pageUrl", dto.PageUrl } }, cancellationToken);
//#endif

//#if (notification == true)
await pushNotificationService.RequestPush(message: dto.Message,
await pushNotificationService.RequestPush(message: dto.Message,
pageUrl: dto.PageUrl,
userRelatedPush: true,
customSubscriptionFilter: s => s.UserSession!.User!.Roles.Any(r => r.RoleId == dto.RoleId),
userRelatedPush: true,
customSubscriptionFilter: s => s.UserSession!.User!.Roles.Any(r => r.RoleId == dto.RoleId),
cancellationToken: cancellationToken);
//#endif
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ string GetValue(string connectionString, string key, string? defaultValue = null
policy.SetIsOriginAllowed(origin => Uri.TryCreate(origin, UriKind.Absolute, out var uri) && settings.IsTrustedOrigin(uri))
.AllowAnyHeader()
.AllowAnyMethod()
.WithExposedHeaders(HeaderNames.RequestId,
.WithExposedHeaders(HeaderNames.RequestId,
HeaderNames.Age, "App-Cache-Response", "X-App-Platform", "X-App-Version", "X-Origin");
});
});
Expand Down Expand Up @@ -228,6 +228,16 @@ string GetValue(string connectionString, string key, string? defaultValue = null
var signalRBuilder = services.AddSignalR(options =>
{
options.EnableDetailedErrors = env.IsDevelopment();
}).AddJsonProtocol(options =>
{
JsonSerializerOptions jsonOptions = new JsonSerializerOptions(AppJsonContext.Default.Options);
jsonOptions.TypeInfoResolverChain.Add(IdentityJsonContext.Default);
jsonOptions.TypeInfoResolverChain.Add(ServerJsonContext.Default);

foreach (var chain in jsonOptions.TypeInfoResolverChain)
{
options.PayloadSerializerOptions.TypeInfoResolverChain.Add(chain);
}
});
if (string.IsNullOrEmpty(configuration["Azure:SignalR:ConnectionString"]) is false)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ private void Handle(Exception exception,
Dictionary<string, object?>? parameters,
HttpContext? httpContext,
out int statusCode,
out ProblemDetails? problemDetails)
out AppProblemDetails? problemDetails)
{
var data = new Dictionary<string, object?>()
{
Expand Down Expand Up @@ -143,7 +143,7 @@ private void Handle(Exception exception,
message = Localizer[message];
}

problemDetails = new ProblemDetails
problemDetails = new AppProblemDetails
{
Title = message,
Status = statusCode,
Expand All @@ -170,7 +170,7 @@ private void Handle(Exception exception,
}
}

public ProblemDetails? Handle(Exception exp,
public AppProblemDetails? Handle(Exception exp,
Dictionary<string, object?>? parameters = null)
{
Handle(UnWrapException(exp), parameters, httpContextAccessor.HttpContext, out var _, out var problemDetails);
Expand Down
Loading