Exemple #1
0
        public override async Task OnConnectedAsync()
        {
            await base.OnConnectedAsync();

            try {
                //  connection.User?.Identity?.Name;
                var client = new OnlineClient(
                    Context.ConnectionId,
                    CommonHelper.GetClientIpAddress(),
                    Current.User != null ? Current.User.Id : (int?)null,
                    Current.Device != null ? Current.Device.Id : (int?)null,
                    SysOptions.SysName);

                OnlineManager.Add(client);

                //Logger.LogInformation( "一个客户端连接: " + client + ":::" + OnlineManager.GetAllClients().Count + ":::id" + Current.Device?.Id);
            }
            catch (Exception ex) {
                Logger.LogError("HubBase Error" + ex.ToString(), ex);
            }
        }