Beispiel #1
0
        public ResponseModel <bool> SetOnline(IWorkerContext context, string userId)
        {
            var key      = "setOnline_" + userId;
            var response = _cache[key] as ResponseModel <bool>;

            if (response == null)
            {
                response = _backend.SetOnline(context, userId);
                _cache.Add(key, response, DateTimeOffset.Now.AddMinutes(5));
            }

            return(response);
        }
Beispiel #2
0
        public ResponseModel <bool> SetOnline(IWorkerContext context, string userId)
        {
            var key   = Pref("SetOnline_" + userId);
            var exist = _redis.GetDatabase().KeyExists(key);

            if (exist)
            {
                return(ResponseModel <bool> .Ok(true));
            }

            _redis.GetDatabase().StringSet(key, "True", TimeSpan.FromMinutes(_setOnlineExpiryInMin), When.Always, CommandFlags.FireAndForget);
            return(_backend.SetOnline(context, userId));
        }
Beispiel #3
0
        public override Task OnConnected()
        {
            try
            {
                var isOnline = _mapper.Any(CurUserId);
                _mapper.Add(CurUserId, Context.ConnectionId);

                InitChatsAndInform(isOnline);

                if (Config.Instance.InformBackendOnlineOffline)
                {
                    Task.Run(() => _backend.SetOnline(WorkerContext, CurUserId));
                }

                Logger.Debug(LogKey);
            }
            catch (Exception e)
            {
                Logger.Error(e);
            }
            return(base.OnConnected());
        }