예제 #1
0
        /// <summary>
        /// 发送当前用户的离线信息
        /// </summary>
        /// <returns></returns>
        public async Task SendOfflineMsg()
        {
            // 所有离线信息
            var lc = new ListCache <string>(MsgKit.MsgQueueKey);
            var ls = await lc.GetRange(UserID);

            if (ls != null && ls.Count > 0)
            {
                try
                {
                    foreach (var mi in ls)
                    {
                        await _writer.Write(mi);
                    }
                    // 删除避免重复推送
                    await lc.Delete(UserID);
                }
                catch (Exception ex)
                {
                    Log.Warning(ex, "向{0}发送离线信息异常", UserID);
                }
            }
        }