public void OnGameHostResponse(HostedGameData data) { if (_waitingRequestId != data.Id) { return; } lock (_users) { Log.InfoFormat("[{0}] Got Hosted Game Data {1}", this, data); if (State != MatchmakingQueueState.WaitingForHostedGame) { // Actually this can happen if someone cancels out of the queue //Log.Fatal("Timeed out before hosted game could be returned. Need to increase timeout."); //this._hostGameTimeout.When = new TimeSpan(0,0,(int)_hostGameTimeout.When.TotalSeconds + 5); return; } // Send all users a message telling them the info they need to connect to game server // Kick all the users from the queue. var message = new Message(new Jid("*****@*****.**"), MessageType.normal, "", "gameready"); message.ChildNodes.Add(data); Log.InfoFormat("[{0}] Sending users game data", this); foreach (var u in _users.Where(x => x.IsInReadyQueue).ToArray()) { message.To = u.JidUser; message.GenerateId(); this.Bot.Xmpp.Send(message); _users.Remove(u); } // set time to game AverageTime.Cycle(); State = MatchmakingQueueState.WaitingForUsers; } }
public MatchmakingQueue(MatchmakingBot bot, Guid gameId, string gameName, string gameMode, int maxPlayers, Version gameVersion, Version octgnVersion) { QueueId = Guid.NewGuid(); GameId = gameId; GameName = gameName; GameMode = gameMode; MaxPlayers = maxPlayers; GameVersion = gameVersion; OctgnVersion = octgnVersion; _users = new List<QueueUser>(); Bot = bot; Bot.Messanger.Map<MatchmakingReadyResponse>(OnMatchmakingReadyResponse); State = MatchmakingQueueState.WaitingForUsers; AverageTime = new AverageTime(10); Log.InfoFormat("[{0}] Queue Created", this); }
public MatchmakingQueue(MatchmakingBot bot, Guid gameId, string gameName, string gameMode, int maxPlayers, Version gameVersion, Version octgnVersion) { QueueId = Guid.NewGuid(); GameId = gameId; GameName = gameName; GameMode = gameMode; MaxPlayers = maxPlayers; GameVersion = gameVersion; OctgnVersion = octgnVersion; _users = new List <QueueUser>(); Bot = bot; Bot.Messanger.Map <MatchmakingReadyResponse>(OnMatchmakingReadyResponse); State = MatchmakingQueueState.WaitingForUsers; AverageTime = new AverageTime(10); Log.InfoFormat("[{0}] Queue Created", this); }