You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
25 lines
761 B
25 lines
761 B
using System;
|
|
using System.Diagnostics;
|
|
using Microsoft.AspNetCore.SignalR;
|
|
|
|
namespace Infrastructure.Web.SignalR
|
|
{
|
|
public class NameUserIdProvider : DefaultUserIdProvider
|
|
{
|
|
public override string GetUserId(HubConnectionContext connection)
|
|
{
|
|
var key = "username";
|
|
var query = connection.GetHttpContext().Request.Query;
|
|
if (query.ContainsKey(key))
|
|
{
|
|
var username = query[key];
|
|
if (!string.IsNullOrEmpty(username))
|
|
{
|
|
Debug.WriteLine($"use userid from request query string {query[key]}");
|
|
return query[key];
|
|
}
|
|
}
|
|
return base.GetUserId(connection);
|
|
}
|
|
}
|
|
} |