QiFeng.ZWY.Bll/Hubs/NotificationHub.cs

(开头部分) 4KB

这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。

using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNet.SignalR;
using QiFeng.LMSD.Model.Dto;

namespace QiFeng.LMSD.Bll.Hubs
{
    public class NotificationHub : Hub, INotifiicationHubServer, INotificationHubClient
    {
        private static readonly Lazy<NotificationHub> LazyNotificationHub;
        private static readonly List<WebConnectedClientInfo> ConnectedUsers = new List<WebConnectedClientInfo>();

        public static NotificationHub Instance
        {
            get { return LazyNotificationHub.Value; }
        }

        public static INotifiicationHubServer Server
        {
            get { return Instance; }
        }

        public static INotificationHubClient Client
        {
            get { return Instance; }
        }

        static NotificationHub()
        {
            LazyNotificationHub =
                new Lazy<NotificationHub>(
                    () =>
                        new NotificationHub
                        {
                            GlobalContext = GlobalHost.ConnectionManager.GetHubContext<NotificationHub>()
                        });
        }

        /// <summary>
        /// 离线
        /// </summary>
        public override Task OnDisconnected(bool stopCalled)
        {
            var item = ConnectedUsers.FirstOrDefault(x => x.ConnectionId == Context.ConnectionId);

            if (item == null) return base.OnDisconnected(stopCalled);

            // GlobalContext.Clients.All.onUserDisconnected(item.ConnectionId, item.ShopId);   //调用客户端用户离线通知
            ConnectedUsers.Remove(item);
            return base.OnDisconnected(stopCalled);
        }

        #region Implement interface 'INotifiicationHubServer'

        /// <summary>
        /// 登录连线
        /// </summary>
        /// <param name="shopId"></param>
后面还有 82 行代码,解锁后查看完整代码

24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明

AI 解读 AI

登录后可用,每次 10 算力,解读结果公开显示在下面。

还没有人解读过这个文件。