public override async Task OnConnectedAsync() { _currentAccount = getAccount(Context); SignalRAccount exists = _ConnectingAccounts.Where(p => p.PersonId == _currentAccount.PersonId).FirstOrDefault(); if (exists == null) { _ConnectingAccounts.Add(_currentAccount); } await base.OnConnectedAsync(); }
public override async Task OnDisconnectedAsync(Exception exception) { _currentAccount = getAccount(Context); SignalRAccount exists = _ConnectingAccounts.Where(p => p.PersonId == _currentAccount.PersonId).FirstOrDefault(); if (exists != null) { _ConnectingAccounts.Remove(exists); } await base.OnDisconnectedAsync(exception); }
private SignalRAccount getAccount(HubCallerContext context) { string personId = string.Empty; personId = context.GetHttpContext().Request.Query["personId"].ToString(); SignalRAccount account = new SignalRAccount() { PersonId = personId, ConnectionId = context.ConnectionId }; return(account); }
private IReadOnlyList <string> GetConnectionIdsFromPersonIds(string[] personIds) { List <string> Ids = new List <string>(); for (int i = 0; i < personIds.Length; i++) { SignalRAccount signalRAccount = _ConnectingAccounts.Where(p => p.PersonId == personIds[i]).FirstOrDefault(); if (signalRAccount != null) { Ids.Add(signalRAccount.ConnectionId); } } return(Ids); }
public override async Task OnDisconnectedAsync(Exception exception) { AccountModel accountModel = new AccountModel(Context.GetHttpContext().GetUserInfo()); if (accountModel != null) { _currentAccount = AutoMapper.Mapper.Map <SignalRAccount>(accountModel.Account); _currentAccount.ConnectionId = Context.ConnectionId; SignalRAccount exists = _ConnectingAccounts.Where(p => p.PersonId == _currentAccount.PersonId).FirstOrDefault(); if (exists != null) { _ConnectingAccounts.Remove(exists); } } await base.OnDisconnectedAsync(exception); }