我想使用signalr向特定用户或用户组发送消息。在此之前,我想将用户映射到连接ID。我正在使用deviceUUId进行用户登录。我无法在GetuserID方法中传递deviceUUID。我从客户端获取deviceUUID并点击api。我可以在MyOwnIdProvider中使用相同的deviceUUID吗?如何映射到用户?
//MyOwnIdProvider///
public class MyOwnIdProvider:IUserIdProvider
{
userDetial dbContext = new userDetial ();
public string GetUserId(IRequest request)
{
if (request == null)
throw new ArgumentNullException("request");
if (request.User != null && request.User.Identity != null)
{
var userId = LogInController.GetLoginDetails(userGUID.UserDeviceId);
return userId.ToString();
}
// return request.User.Identity.Name;
else
return (string)null;
}
}
///API controller///
public class LogInController : ApiController
{
[System.Web.Http.HttpPost]
public int GetLoginDetails(userModel UserDeviceId)
{
var LogindeviceID = db.loginDetails(UserDeviceId.DeviceUUID);
return LogindeviceID;
}
}