public async Task LoginAs(PlayerDto player) { if (_connectionCache.ContainsKey(Context.ConnectionId)) { _connectionCache.Remove(Context.ConnectionId); await Clients.All.SendAsync("PlayerLeft", player); } _connectionCache.Add(Context.ConnectionId, player); await Clients.Others.SendAsync("PlayerEntered", player); await Clients.Caller.SendAsync("LoggedIn", new { onlinePlayers = _connectionCache.Values }); }
private static IScheduler _getScheduler(string ip) { if (!ConnectionCache.ContainsKey(ip)) { var properties = new NameValueCollection(); properties["quartz.scheduler.proxy"] = "true"; properties["quartz.scheduler.proxy.address"] = $"{channelType}://{localIp}:{port}/{bindName}"; var schedulerFactory = new StdSchedulerFactory(properties); _scheduler = schedulerFactory.GetScheduler().Result; ConnectionCache[ip] = _scheduler; } return(ConnectionCache[ip]); }