public Task SellerSideWalletBal(string Token, string WalletName, string Data) { try { //_chatHubContext.Clients.Group("SellerSideWalletBal:" + Pair).SendAsync("RecieveSellerSideWalletBal", Data); //++++++++++++++++++++++// //var Redis = new RadisServices<ConnetedClientList>(this._fact); //ConnetedClientList User = new ConnetedClientList(); //User = Redis.GetConnectionID(Token); //_chatHubContext.Clients.Client(User.ConnectionId).SendAsync("RecieveSellerSideWalletBal", Data); var Redis = new RadisServices <ConnetedClientToken>(this._fact); IEnumerable <string> ClientList = Redis.GetKey(Token); foreach (string s in ClientList.ToList()) { var Key = s; Key = Key.Split(":")[1].ToString(); string Pair = Redis.GetPairOrMarketData(Key, ":", "Pairs"); if (Pair.Split("_")[0].ToString() == WalletName) { _chatHubContext.Clients.Client(Key).SendAsync(Enum.GetName(typeof(enReturnMethod), enReturnMethod.RecieveSellerSideWalletBal), Data); HelperForLog.WriteLogIntoFile("SellerSideWalletBal", "SocketHub", " Send Data :" + Data); } else { // ignore Data } } return(Task.FromResult(0)); } catch (Exception ex) { _logger.LogError(ex, "An unexpected exception occured,\nMethodName:" + System.Reflection.MethodBase.GetCurrentMethod().Name + "\nClassname=" + this.GetType().Name, LogLevel.Error); return(Task.FromResult(0)); } }
public override Task OnDisconnectedAsync(System.Exception exception) { try { //var Redis = new RadisServices<ConnetedClientList>(this._fact); //Redis.Scan(Context.ConnectionId, ":ConnectionDetail"); var Redis = new RadisServices <ConnetedClientToken>(this._fact); string Pair = Redis.GetPairOrMarketData(Context.ConnectionId, ":", "Pairs"); string BaseCurrency = Redis.GetPairOrMarketData(Context.ConnectionId, ":", "Markets"); //GetConnectedClient(Pair); ConnetedClientToken Client = new ConnetedClientToken(); Client = Redis.GetData("Users:" + Context.ConnectionId); if (Client != null) { Redis.DeleteTag("Users:" + Context.ConnectionId, Client.Token); } Redis.DeleteTag("Pairs:" + Pair, Context.ConnectionId); Redis.DeleteTag("Markets:" + BaseCurrency, Context.ConnectionId); Redis.DeleteHash("Users:" + Context.ConnectionId); Redis.RemoveSetMember("Pairs:" + Pair, Context.ConnectionId); Redis.RemoveSetMember("Markets:" + BaseCurrency, Context.ConnectionId); Groups.RemoveFromGroupAsync(Context.ConnectionId, "BuyerBook:" + Pair).Wait(); Groups.RemoveFromGroupAsync(Context.ConnectionId, "SellerBook:" + Pair).Wait(); Groups.RemoveFromGroupAsync(Context.ConnectionId, "TradingHistory:" + Pair).Wait(); Groups.RemoveFromGroupAsync(Context.ConnectionId, "MarketData:" + Pair).Wait(); Groups.RemoveFromGroupAsync(Context.ConnectionId, "ChartData:" + Pair).Wait(); Groups.RemoveFromGroupAsync(Context.ConnectionId, "Price:" + Pair).Wait(); Groups.RemoveFromGroupAsync(Context.ConnectionId, "BroadCast").Wait(); Groups.RemoveFromGroupAsync(Context.ConnectionId, "GroupMessage").Wait(); Groups.RemoveFromGroupAsync(Context.ConnectionId, "PairData:" + BaseCurrency).Wait(); Groups.RemoveFromGroupAsync(Context.ConnectionId, "MarketTicker:" + BaseCurrency).Wait(); return(base.OnDisconnectedAsync(exception)); } catch (Exception ex) { _logger.LogError(ex, "An unexpected exception occured,\nMethodName:" + System.Reflection.MethodBase.GetCurrentMethod().Name + "\nClassname=" + this.GetType().Name, LogLevel.Error); return(Task.FromResult(0)); } }