public ISignal CreateSignal(object value, int expireMinutes) { var signal = new RedisSignal() { TenantType = _tentantType, TenantId = _tentantId, UId = RandomKey.GetKey(), Value = value }; signal.Store(expireMinutes); return(signal); }
/// <summary> /// 登录并且记录当前用户的登录标记 /// </summary> /// <param name="userRedisModel">当前登录信息</param> /// <returns>登录标记</returns> public string SignIn(UserRedisModel userRedisModel) { var signal = internalConsumer.GetSignal(userRedisModel.UserName); string loginKey = RandomKey.GetKey(); #region 释放已经登录信号,创建新的登录信号 if (signal != null) { LoginChannel.ChannelInstance.Logout(userRedisModel); internalConsumer.ReleaseSignal(signal); } internalConsumer.ApplyFor(userRedisModel.UserName, loginKey); #endregion #region 客户端写入SignalRId var signalRId = new HttpCookie(CookieKey.SignalRId) { Name = CookieKey.SignalRId, Expires = DateTime.Now.AddDays(1), Value = loginKey }; HttpContext.Current.Response.Cookies.Add(signalRId); #endregion return(loginKey); }