internal void OnLobbyCreatedAPI(LobbyCreated_t callback, bool error) { //from SpaceWarClient.cpp 793 if (error || (callback.Result != Result.OK)) { if (OnLobbyCreated != null) { OnLobbyCreated(false); } return; } //set owner specific properties Owner = client.SteamId; CurrentLobby = callback.SteamIDLobby; CurrentLobbyData = new LobbyData(client, CurrentLobby); Name = client.Username + "'s Lobby"; CurrentLobbyData.SetData("appid", client.AppId.ToString()); LobbyType = createdLobbyType; CurrentLobbyData.SetData("lobbytype", LobbyType.ToString()); Joinable = true; if (OnLobbyCreated != null) { OnLobbyCreated(true); } }
internal void UpdateArtPathAndCheckForUpdatesAndLoginToLobby(LobbyType lobbyType) { this.Enabled = false; switch (lobbyType) { case LobbyType.Production: AllegianceRegistry.ArtPath = AllegianceRegistry.ProductionArtPath; AllegianceRegistry.CfgFile = AllegianceRegistry.ProductionCfgFile; break; case LobbyType.Beta: AllegianceRegistry.ArtPath = AllegianceRegistry.BetaArtPath; AllegianceRegistry.CfgFile = AllegianceRegistry.BetaCfgFile; break; default: throw new NotSupportedException(lobbyType.ToString()); } // Don't request updates for offline play. if (RequestUpdateCheck != null && lobbyType != LobbyType.None) { RequestUpdateCheck(lobbyType, LoginToLobby); } else { LoginToLobby(lobbyType); } }
void _playControl_RequestUpdateCheck(LobbyType lobbyType, PlayControl.LoginToLobbyCallback loginToLobbyCallback) { _updateCheckControl = new UpdateCheckControl(); if (_updateCheckControl.HasPendingUpdates == true) { SystemWatcher.Close(); _playControl.Visible = false; _updateCheckControl.Parent = _mainTabControl.TabPages[0]; _updateCheckControl.Dock = DockStyle.Fill; _updateCheckControl.AutoupdateComplete += new UpdateCheckControl.AutoupdateCompleteHandler(delegate(bool updateCanceled) { _updateCheckControl.Visible = false; _playControl.Visible = true; if (updateCanceled == false) { SystemWatcher.InitializeWithAutoupdateProtectedFileList(); loginToLobbyCallback(lobbyType); } }); _updateCheckControl.Show(); } else { SystemWatcher.InitializeWithAutoupdateProtectedFileList(); loginToLobbyCallback(lobbyType); } }
public void CreateRoom(string roomName, string lobbyName = "myLobby", LobbyType lobbyType = LobbyType.SqlLobby, string[] expectedUsers = null) { if (debug) { Debug.Log("PunCockpit:CreateRoom roomName:" + roomName + " lobbyName:" + lobbyName + " lobbyType:" + lobbyType + " expectedUsers:" + (expectedUsers == null ? "null" : expectedUsers.ToStringFull())); } this.RoomListManager.ResetList(); this.LobbyPanel.gameObject.SetActive(false); this.ConnectingLabel.SetActive(true); RoomOptions _roomOptions = this.GetRoomOptions(); if (debug) { Debug.Log("PunCockpit:Room options <" + _roomOptions + ">"); } TypedLobby sqlLobby = new TypedLobby(lobbyName, lobbyType); bool _result = PhotonNetwork.CreateRoom(roomName, _roomOptions, sqlLobby, expectedUsers); if (debug) { Debug.Log("PunCockpit:CreateRoom() -> " + _result); } }
private void ProcessLobby( XmlElement element, DiplomacyActionWeights.DiplomacyActionWeight weight) { LobbyType lobbyType = (LobbyType)Enum.Parse(typeof(LobbyType), element.GetAttribute("type")); weight.Type = (object)lobbyType; }
private static string LobbyIdJson(LobbyType lobbyType, string lobbyId) { var lobbyIdJson = new LobbyId() { lobbyId = lobbyId }; var jsonString = JsonConvert.SerializeObject(lobbyIdJson); return(JsonCreator.RemoveSlash(JsonCreator.CreateJson(lobbyType.ToString(), jsonString))); }
/// <summary> /// Marks a lobby as private or public. /// </summary> /// <param name="type"></param> public void SetType(LobbyType type) { if (MethodsPtr != IntPtr.Zero) { Result res = Methods.SetType(MethodsPtr, type); if (res != Result.Ok) { throw new ResultException(res); } } }
private bool IsLobbyAvailable(LobbyType lobbyType) { foreach (LobbyResult lobby in AvailableLobbies) { if (lobby.Name.Equals(lobbyType.ToString(), StringComparison.InvariantCultureIgnoreCase) == true) { return(true); } } return(false); }
// Creates a lobby with specified parameters public void CreateLobby(LobbyType lobbyType, uint maxMembers, bool joinable, LobbyTopologyType lobbyTopologyType) { Debug.Log("Creating a lobby"); try { GalaxyInstance.Matchmaking().CreateLobby(lobbyType, maxMembers, joinable, lobbyTopologyType); } catch (GalaxyInstance.Error e) { Debug.LogWarning("Could not create lobby for reason: " + e); } }
private void startLobby(LobbyType lobbyType) { ButtonsHolder.SetActive(false); if (lobbyType == LobbyType.PRIVATE) { SteamMatchmaking.CreateLobby(ELobbyType.k_ELobbyTypeFriendsOnly, networkManager.maxConnections); } if (lobbyType == LobbyType.PUBLIC) { SteamMatchmaking.CreateLobby(ELobbyType.k_ELobbyTypePublic, networkManager.maxConnections); } }
// SteamAPICall_t public CallbackHandle CreateLobby(LobbyType eLobbyType /*ELobbyType*/, int cMaxMembers /*int*/, Action <LobbyCreated_t, bool> CallbackFunction = null /*Action<LobbyCreated_t, bool>*/) { SteamAPICall_t callback = 0; callback = platform.ISteamMatchmaking_CreateLobby(eLobbyType, cMaxMembers); if (CallbackFunction == null) { return(null); } return(LobbyCreated_t.CallResult(steamworks, callback, CallbackFunction)); }
// Creates a lobby with specified parameters public void CreateLobby(string gameName, LobbyType lobbyType, uint maxMembers, bool joinable, LobbyTopologyType lobbyTopologyType) { Debug.Log("Creating a lobby"); try { lobbyName = gameName; Debug.Assert(lobbyCreatedListener != null); GalaxyInstance.Matchmaking().CreateLobby(lobbyType, maxMembers, joinable, lobbyTopologyType, lobbyCreatedListener); } catch (GalaxyInstance.Error e) { Debug.LogWarning("Could not create lobby for reason: " + e); } }
public void SubmitForm() { LobbyType _t = LobbyType.Default; if (LobbyTypeInput.value == 1) { _t = LobbyType.SqlLobby; } else if (LobbyTypeInput.value == 2) { _t = LobbyType.AsyncRandomLobby; } string[] _expectedUsers = string.IsNullOrEmpty(ExpectedUsersInput.text) ? null : ExpectedUsersInput.text.Split(',').Select(t => t.Trim()).ToArray(); OnSubmit.Invoke( string.IsNullOrEmpty(RoomNameInput.text) ? null : RoomNameInput.text, string.IsNullOrEmpty(LobbyNameInput.text) ? null : LobbyNameInput.text, _t, _expectedUsers); }
public LoadingLobbyView(LobbyType type, int lobbyID = 0) { InitializeComponent(); if (type == LobbyType.Host) { StatusText.Text = "Creating A Lobby..."; MiddleManAPI.HostLobby(); MiddleManAPI.LobbyCreated += () => Dispatcher?.Invoke(() => ViewController.SetView(new LobbyView(new HostLobby()))); } else if (type == LobbyType.User) { if (lobbyID == 0) { Dispatcher?.Invoke(() => ViewController.SetView(new LobbyListView())); } else { StatusText.Text = "Connecting To Lobby #" + lobbyID + "..."; MiddleManAPI.JoinLobby(lobbyID); MiddleManAPI.JoinLobbySuccess += (Socket connection) => Dispatcher?.Invoke(() => ViewController.SetView(new LobbyView(new UserLobby(connection)))); MiddleManAPI.JoinLobbyFailure += () => Dispatcher?.Invoke(() => ViewController.SetView(new LobbyListView())); } } }
public void GetGameUpdate_LobbyPropertyRemove([Values(LobbyType.Default, LobbyType.SqlLobby)] LobbyType lobbyType) { UnifiedTestClient client1 = null; UnifiedTestClient client2 = null; var lobbyFilterCase = LobbyFilterContent.LobbyFilterNonEmpty; var lobbyName = this.GenerateRandomizedRoomName(MethodBase.GetCurrentMethod().Name + "_Lobby"); var lobbyFilter = SetupLobbyFilter(lobbyFilterCase); string propertyName = "InLobbyFilterList"; try { // authenticate client and check if the Lobbystats event will be received // Remarks: The event cannot be checked for a specific lobby count because // previous tests may have created lobbies. client1 = this.CreateMasterClientAndAuthenticate(this.Player1); if (string.IsNullOrEmpty(this.Player1) || client1.Token == null) { Assert.Ignore("This test does not work correctly for old clients without userId and token"); } client1.JoinLobby(lobbyName, (byte)lobbyType); // create a new game for the lobby var gameName = this.GenerateRandomizedRoomName(MethodBase.GetCurrentMethod().Name); var createGameRequest = new CreateGameRequest { GameId = gameName, RoomFlags = RoomOptionFlags.DeleteNullProps, GameProperties = new Hashtable() { { "z", "w" }, { propertyName, "Value" }, { (byte)GameParameter.LobbyProperties, lobbyFilter } } }; var createGameResponse = client1.CreateGame(createGameRequest); this.ConnectAndAuthenticate(client1, createGameResponse.Address, client1.UserId); client1.CreateGame(createGameRequest); // give the game server some time to report the game to the master server Thread.Sleep(100); var authParameter = new Dictionary <byte, object> { { (byte)Operations.ParameterCode.LobbyStats, true } }; // check if new game is listed in lobby statistics client2 = this.CreateMasterClientAndAuthenticate(this.Player2, authParameter); if (this.AuthPolicy == AuthPolicy.UseAuthOnce) // in this case we should send OpSettings to master { client2.SendRequest(new OperationRequest { OperationCode = (byte)OperationCode.ServerSettings, Parameters = new Dictionary <byte, object> { { SettingsRequestParameters.LobbyStats, true } }, }); } client2.JoinLobby(lobbyName, (byte)lobbyType); client1.SendRequest(new OperationRequest { OperationCode = OperationCode.SetProperties, Parameters = new Dictionary <byte, object> { { ParameterCode.Properties, new Hashtable { { propertyName, "xx" } } }, } }); Thread.Sleep(100); var gameListUpdate = client2.WaitForEvent((byte)Events.EventCode.GameListUpdate, this.WaitTimeout); var gameList = (Hashtable)gameListUpdate.Parameters[(byte)ParameterKey.GameList]; var propertyList = (Hashtable)gameList[gameName]; Assert.That(propertyList[propertyName], Is.EqualTo("xx")); client1.SendRequest(new OperationRequest { OperationCode = OperationCode.SetProperties, Parameters = new Dictionary <byte, object> { { ParameterCode.Properties, new Hashtable { { propertyName, null } } }, } }); Thread.Sleep(100); gameListUpdate = client2.WaitForEvent((byte)Events.EventCode.GameListUpdate, this.WaitTimeout); gameList = (Hashtable)gameListUpdate.Parameters[(byte)ParameterKey.GameList]; propertyList = (Hashtable)gameList[gameName]; Assert.That(propertyList.Contains(propertyName), Is.False); } finally { DisposeClients(client1, client2); } }
public bool OpCreateRoom(string roomName, bool isVisible, bool isOpen, byte maxPlayers, Hashtable customGameProperties, string[] propsListedInLobby, string lobbyName, LobbyType lobbyType, int playerTtl, int roomTtl) { this.State = ClientState.Joining; this.lastJoinType = JoinType.CreateRoom; this.lastJoinActorNumber = 0; this.createRoomOptions = new RoomOptions() { IsVisible = isVisible, IsOpen = isOpen, MaxPlayers = maxPlayers, PlayerTtl = playerTtl, EmptyRoomTtl = roomTtl, CleanupCacheOnLeave = true, CustomRoomProperties = customGameProperties, CustomRoomPropertiesForLobby = propsListedInLobby }; this.CurrentRoom = this.CreateRoom(roomName, this.createRoomOptions); Hashtable playerPropsToSend = null; if (this.Server == ServerConnection.GameServer) { playerPropsToSend = this.LocalPlayer.AllProperties; } this.CurrentLobby = new TypedLobby(lobbyName, lobbyType); bool onGameServer = this.Server == ServerConnection.GameServer; return this.loadBalancingPeer.OpCreateRoom(roomName, this.createRoomOptions, new TypedLobby(lobbyName, lobbyType), playerPropsToSend, onGameServer); }
internal void UpdateArtPathAndCheckForUpdatesAndLoginToLobby(LobbyType lobbyType) { this.Enabled = false; switch (lobbyType) { case LobbyType.Production: AllegianceRegistry.ArtPath = AllegianceRegistry.ProductionArtPath; AllegianceRegistry.CfgFile = AllegianceRegistry.ProductionCfgFile; break; case LobbyType.Beta: AllegianceRegistry.ArtPath = AllegianceRegistry.BetaArtPath; AllegianceRegistry.CfgFile = AllegianceRegistry.BetaCfgFile; break; default: throw new NotSupportedException(lobbyType.ToString()); } // Don't request updates for offline play. if (RequestUpdateCheck != null && lobbyType != LobbyType.None) RequestUpdateCheck(lobbyType, LoginToLobby); else LoginToLobby(lobbyType); }
public static void StartAllegiance(string ticket, LobbyType lobbyType, string alias, TaskDelegate onCompleteDelegate) { DebugDetector.AssertCheckRunning(); TaskHandler.RunTask(delegate(object p) { var param = p as object[]; var sessionTicket = param[0] as string; var signal = param[1] as TaskDelegate; var succeeded = false; try { AllegianceRegistry.OutputDebugString = DataStore.Preferences.DebugLog; AllegianceRegistry.LogToFile = DataStore.Preferences.DebugLog; AllegianceRegistry.LogChat = DataStore.Preferences.LogChat; //Create commandline var commandLine = new StringBuilder("-authenticated") .AppendFormat(" -callsign={0}", alias); if (DataStore.Preferences.DebugLog) commandLine.Append(" -debug"); if (DataStore.Preferences.LaunchWindowed) commandLine.Append(" -windowed"); if (DataStore.Preferences.NoMovies) commandLine.Append(" -nomovies"); //Start Allegiance string lobbyPath = Path.Combine(AllegianceRegistry.LobbyPath, lobbyType.ToString()); string allegiancePath = Path.Combine(lobbyPath, "Allegiance.exe"); if(DataStore.Preferences.UseDX7Engine == true) allegiancePath = Path.Combine(lobbyPath, "AllegianceDX7.exe"); #if DEBUG if (String.IsNullOrEmpty(ConfigurationManager.AppSettings["AllegianceExeOverride"]) == false) { Log.Write("Allegiance path was overridden by configuration setting."); allegiancePath = ConfigurationManager.AppSettings["AllegianceExeOverride"]; } #endif Log.Write("Using: " + allegiancePath + " " + commandLine.ToString() + " to launch..."); ProcessHandler process = ProcessHandler.Start(allegiancePath, commandLine.ToString()); process.OnExiting += new EventHandler(process_OnExiting); _allegianceProcess = process; _allegianceProcessMonitor = new ProcessMonitor(_allegianceProcess); // If launching into a lobby, then relay the security token to the allegiance process. if (lobbyType != LobbyType.None) { //Open Pipe using (var reset = new ManualResetEvent(false)) { TaskHandler.RunTask(delegate(object value) { var parameters = value as object[]; var localProcessHandler = parameters[0] as ProcessHandler; var localSessionTicket = parameters[1] as String; var localReset = parameters[2] as ManualResetEvent; using (var pipe = new Pipe(@"\\.\pipe\allegqueue")) { pipe.Create(); if (pipe.Connect()) { Int64 memoryLocation = Int64.Parse(pipe.Read()); localProcessHandler.WriteMemory(memoryLocation, localSessionTicket + (char) 0x00 + Process.GetCurrentProcess().Id); localReset.Set(); } } }, process, sessionTicket, reset); //Wait X seconds, if allegiance does not retrieve the ticket, exit Allegiance. if (!reset.WaitOne(PipeTimeout)) { try { process.ForceClose(); //Connect to the pipe in order to close out the connector thread. using (var pipe = new Pipe(@"\\.\pipe\allegqueue")) { pipe.OpenExisting(); pipe.Read(); } } catch { } finally { throw new Exception("Allegiance did not respond within the time allotted."); } } // The memory address was retrived from the pipe, write the ticket onto the target process. //process.WriteMemory((Int64) memoryLocation, sessionTicket); } } succeeded = true; } catch (Exception error) { Log.Write(error); } finally { signal(succeeded); } }, ticket, onCompleteDelegate); }
public TypedLobby() { this.Name = string.Empty; this.Type = LobbyType.Default; }
private bool IsLobbyAvailable(LobbyType lobbyType) { foreach (LobbyResult lobby in AvailableLobbies) { if (lobby.Name.Equals(lobbyType.ToString(), StringComparison.InvariantCultureIgnoreCase) == true) return true; } return false; }
internal CallResult <LobbyCreated_t> CreateLobby(LobbyType eLobbyType, int cMaxMembers) { var returnValue = _CreateLobby(Self, eLobbyType, cMaxMembers); return(new CallResult <LobbyCreated_t>(returnValue)); }
internal bool SetLobbyType(SteamId steamIDLobby, LobbyType eLobbyType) { var returnValue = _SetLobbyType(Self, steamIDLobby, eLobbyType); return(returnValue); }
public bool OpCreateRoom(string roomName, bool isVisible, bool isOpen, byte maxPlayers, Hashtable customGameProperties, string[] propsListedInLobby, string lobbyName, LobbyType lobbyType) { return this.OpCreateRoom(roomName, isVisible, isOpen, maxPlayers, customGameProperties, propsListedInLobby, null, LobbyType.Default, 0, 0); }
internal async Task <LobbyCreated_t?> CreateLobby(LobbyType eLobbyType, int cMaxMembers) { var returnValue = _CreateLobby(Self, eLobbyType, cMaxMembers); return(await LobbyCreated_t.GetResultAsync(returnValue)); }
public bool LoadXml(string Hash) { string FileName = "replay/" + Hash + ".xml"; XmlLoad X = new XmlLoad(); if (!X.Load(FileName)) return false; while (X.Read()) { switch (X.ElementName) { case "hash": this.Hash = X.GetAttribute("value"); break; case "playercount": PlayerCount = X.GetIntAttribute("value"); break; case "lobby": Lobby = X.GetIntAttribute("value"); break; case "lobbytype": LobbyType = (LobbyType)X.GetIntAttribute("value"); break; case "balance": Balance = X.ReadIntArray(); break; case "result": Result = X.ReadIntArray(); break; case "place": Place = X.ReadIntArray(); break; case "playerlist": { int Count = 4; XmlLoad Subtree = X.GetSubtree(); for (int j = 0; j < Count; j++) { Players[j] = new Player(); Players[j].ReadXml(Subtree); } Subtree.Close(); } break; case "roundlist": { int Count = X.GetIntAttribute("count"); XmlLoad Subtree = X.GetSubtree(); for (int j = 0; j < Count; j++) { if (!Subtree.Read()) break; switch (Subtree.ElementName) { case "round": string FName = Subtree.GetAttribute("filename"); int Index = Subtree.GetIntAttribute("index"); Round R = new Round(); Rounds.Add(R); RoundFiles.Add(FName); XmlLoad RoundData = Subtree.GetSubtree(); while (RoundData.Read()) { switch (Subtree.ElementName) { case "round": R.CurrentRound = RoundData.GetIntAttribute("index"); break; case "renchan": R.RenchanStick = RoundData.GetIntAttribute("index"); break; case "result": R.StringResult = RoundData.GetAttribute("value"); break; case "balancebefore": R.BalanceBefore = RoundData.ReadIntArray(); break; case "balanceafter": R.BalanceAfter = RoundData.ReadIntArray(); break; case "pay": R.Pay = RoundData.ReadIntArray(); break; case "han": R.HanCount = RoundData.ReadIntArray(); break; case "fu": R.FuCount = RoundData.ReadIntArray(); break; case "cost": R.Cost = RoundData.ReadIntArray(); break; case "winner": R.Winner = RoundData.ReadBoolArray(); break; case "loser": R.Loser = RoundData.ReadBoolArray(); break; case "openedsets": R.OpenedSets = RoundData.ReadIntArray(); break; case "riichi": R.Riichi = RoundData.ReadIntArray(); break; case "dealer": R.Dealer = RoundData.ReadBoolArray(); break; } } RoundData.Close(); // try to load more data R.Load(FName); break; } } Subtree.Close(); } break; } } Date = GetDateTimeFromHash(Hash); return true; }
internal bool SetLobbyType(SteamId steamIDLobby, LobbyType eLobbyType) { return(_SetLobbyType(Self, steamIDLobby, eLobbyType)); }
internal async Task <LobbyCreated_t?> CreateLobby(LobbyType eLobbyType, int cMaxMembers) { return(await LobbyCreated_t.GetResultAsync(_CreateLobby( Self, eLobbyType, cMaxMembers ))); }
public void GetGameUpdate_PluginSetStateOnCreation([Values(LobbyType.Default, LobbyType.SqlLobby)] LobbyType lobbyType) { if (!this.UsePlugins) { Assert.Ignore("This test needs plugins"); } UnifiedTestClient client1 = null; UnifiedTestClient client2 = null; var lobbyFilterCase = LobbyFilterContent.LobbyFilterNonEmpty; var lobbyName = this.GenerateRandomizedRoomName(MethodBase.GetCurrentMethod().Name + "_Lobby"); var lobbyFilter = SetupLobbyFilter(lobbyFilterCase); try { // authenticate client and check if the Lobbystats event will be received // Remarks: The event cannot be checked for a specific lobby count because // previous tests may have created lobbies. client1 = this.CreateMasterClientAndAuthenticate(this.Player1); if (string.IsNullOrEmpty(this.Player1) || client1.Token == null) { Assert.Ignore("This test does not work correctly for old clients without userId and token"); } client1.JoinLobby(lobbyName, (byte)lobbyType); // create a new game for the lobby var gameName = this.GenerateRandomizedRoomName(MethodBase.GetCurrentMethod().Name); var request = new CreateGameRequest { GameId = gameName, LobbyType = (byte)lobbyType, LobbyName = lobbyName, Plugins = new [] { "SaveLoadStateTestPlugin" }, GameProperties = new Hashtable { { "xxx", 1 }, { "yyy", 2 }, { GameParameter.LobbyProperties, new [] { "xxx" } } }, }; var createGameResponse = client1.CreateGame(request); this.ConnectAndAuthenticate(client1, createGameResponse.Address, client1.UserId); client1.CreateGame(request); // give the game server some time to report the game to the master server Thread.Sleep(100); client1.Disconnect();// after disconnect game state is saved Thread.Sleep(100); var authParameter = new Dictionary <byte, object> { { (byte)Operations.ParameterCode.LobbyStats, true } }; // check if new game is listed in lobby statistics client2 = this.CreateMasterClientAndAuthenticate(this.Player2, authParameter); if (this.AuthPolicy == AuthPolicy.UseAuthOnce) // in this case we should send OpSettings to master { client2.SendRequest(new OperationRequest { OperationCode = (byte)OperationCode.ServerSettings, Parameters = new Dictionary <byte, object> { { SettingsRequestParameters.LobbyStats, true } }, }); } client2.JoinLobby(lobbyName, (byte)lobbyType); Thread.Sleep(3000); client2.EventQueueClear(); var joinRequest = new JoinGameRequest { GameId = gameName, LobbyType = (byte)lobbyType, LobbyName = lobbyName, Plugins = new string[] { "SaveLoadStateTestPlugin" }, JoinMode = (byte)JoinMode.JoinOrRejoin, }; this.ConnectAndAuthenticate(client1, this.MasterAddress); var jgResponse = client1.JoinGame(joinRequest); this.ConnectAndAuthenticate(client1, jgResponse.Address); client1.JoinGame(joinRequest); EventData eventData; Assert.That(client2.TryWaitForEvent((byte)Events.EventCode.GameListUpdate, this.WaitTimeout, out eventData)); Assert.That(eventData.Parameters.Count > 0); var gameList = (Hashtable)eventData.Parameters[(byte)ParameterKey.GameList]; var propertyList = (Hashtable)gameList[gameName]; Assert.That(propertyList["xxx"], Is.EqualTo(1)); } finally { DisposeClients(client1, client2); } }
public void GetGameUpdate_WellKnownPropertyChange( [Values(GameParameter.IsVisible, GameParameter.IsOpen)] GameParameter gameParameter, [Values(LobbyType.Default, LobbyType.SqlLobby)] LobbyType lobbyType) { UnifiedTestClient client1 = null; UnifiedTestClient client2 = null; var lobbyFilterCase = LobbyFilterContent.LobbyFilterNonEmpty; var lobbyName = this.GenerateRandomizedRoomName(MethodBase.GetCurrentMethod().Name + "_Lobby"); var lobbyFilter = SetupLobbyFilter(lobbyFilterCase); try { // authenticate client and check if the Lobbystats event will be received // Remarks: The event cannot be checked for a specific lobby count because // previous tests may have created lobbies. client1 = this.CreateMasterClientAndAuthenticate(this.Player1); if (string.IsNullOrEmpty(this.Player1) || client1.Token == null) { Assert.Ignore("This test does not work correctly for old clients without userId and token"); } client1.JoinLobby(lobbyName, (byte)lobbyType); // create a new game for the lobby var gameName = this.GenerateRandomizedRoomName(MethodBase.GetCurrentMethod().Name); var createGameResponse = client1.CreateGame(gameName, true, true, 0, new Hashtable() { { "z", "w" } }, lobbyFilter, null); this.ConnectAndAuthenticate(client1, createGameResponse.Address, client1.UserId); client1.CreateGame(gameName, true, true, 0, new Hashtable() { { "z", "w" } }, lobbyFilter, null); // give the game server some time to report the game to the master server Thread.Sleep(100); var authParameter = new Dictionary <byte, object> { { (byte)Operations.ParameterCode.LobbyStats, true } }; // check if new game is listed in lobby statistics client2 = this.CreateMasterClientAndAuthenticate(this.Player2, authParameter); if (this.AuthPolicy == AuthPolicy.UseAuthOnce) // in this case we should send OpSettings to master { client2.SendRequest(new OperationRequest { OperationCode = (byte)OperationCode.ServerSettings, Parameters = new Dictionary <byte, object> { { SettingsRequestParameters.LobbyStats, true } }, }); } client2.JoinLobby(lobbyName, (byte)lobbyType); Thread.Sleep(3000); client2.EventQueueClear(); client1.SendRequest(new OperationRequest { OperationCode = OperationCode.SetProperties, Parameters = new Dictionary <byte, object> { { ParameterCode.Properties, new Hashtable { { (byte)gameParameter, false } } }, } }); client2.CheckThereIsEvent((byte)Events.EventCode.GameListUpdate, this.WaitTimeout); // we send same value again client1.SendRequest(new OperationRequest { OperationCode = OperationCode.SetProperties, Parameters = new Dictionary <byte, object> { { ParameterCode.Properties, new Hashtable { { (byte)gameParameter, false } } }, } }); client2.CheckThereIsNoEvent((byte)Events.EventCode.GameListUpdate, this.WaitTimeout); } finally { DisposeClients(client1, client2); } }
private static extern SteamAPICall_t _CreateLobby(IntPtr self, LobbyType eLobbyType, int cMaxMembers);
private static extern bool _SetLobbyType(IntPtr self, SteamId steamIDLobby, LobbyType eLobbyType);
internal void LoginToLobby(LobbyType lobbyType) { //Verify the form is filled out if (string.IsNullOrEmpty(_loginComboBox.Text)) return; // TODO: Figure out where the alleg exe is and send it to the launcher. //Create a new session var signal = new TaskDelegate(delegate(object input) { var parameters = input as object[]; var status = (CheckInStatus)parameters[0]; var message = parameters[1] as string; var alias = parameters[2] as string; var ticket = parameters[3] as string; int rank = 0; if (parameters[4] != null) rank = (int)parameters[4]; Regex aliasFinder = new Regex( "(?<callsign>.*?)(\\(\\d+\\))?$", RegexOptions.ExplicitCapture | RegexOptions.CultureInvariant | RegexOptions.Compiled ); var match = aliasFinder.Match(alias); if (match.Success == true) alias = match.Groups["callsign"].Value; if (status == CheckInStatus.AccountLinked) { if (ReloadCallsigns != null) ReloadCallsigns(); } if (status == CheckInStatus.Ok || status == CheckInStatus.AccountLinked) { //Initialize check-in interval CheckInTimer = new Timer(); CheckInTimer.Interval = CheckInInterval; CheckInTimer.Tick += new EventHandler(CheckInTimer_Tick); CheckInTimer.Start(); //Launch Allegiance MainForm.SetStatusBar("Launching Allegiance..."); //Store last-used alias if (!string.Equals(DataStore.LastAlias, alias)) { DataStore.LastAlias = alias; DataStore.Instance.Save(); } if (rank <= 5) alias += "(" + rank + ")"; AllegianceLoader.StartAllegiance(ticket, lobbyType, alias, delegate(object param) { var result = (bool)param; if (!result) { Logout(); MainForm.SetStatusBar("Failed to launch Allegiance."); } else { //AllegianceLoader.AllegianceProcess.OnExiting // += new EventHandler(AllegianceProcess_OnExiting); AllegianceLoader.AllegianceExit += new EventHandler(AllegianceProcess_OnExiting); } }); SetLoggedIn(true); if (DataStore.Preferences.AutoLogin) MainForm.HideForm(); } else { MainForm.SetStatusBar(message); if (status == CheckInStatus.VirtualMachineBlocked) { VirtualMachineInfo virtualMachineInfo = new VirtualMachineInfo(); virtualMachineInfo.ShowDialog(); } this.Enabled = true; SystemWatcher.Close(); } }); SessionNegotiator.Login(_loginComboBox.Text, lobbyType.ToString(), delegate(object input) { if (this.InvokeRequired) this.Invoke(signal, input); else signal(input); }); }
public void Load(string FileName) { FileName = "round/" + FileName; XmlLoad X = new XmlLoad(); if (!X.Load(FileName)) return; this.FileName = FileName; while (X.Read()) { switch (X.ElementName) { case "hash": Hash = X.GetAttribute("value"); break; case "playercount": PlayerCount = X.GetIntAttribute("value"); break; case "lobby": Lobby = X.GetIntAttribute("value"); break; case "lobbytype": LobbyType = (LobbyType)X.GetIntAttribute("value"); break; case "game": Index = X.GetIntAttribute("index"); break; case "round": CurrentRound = X.GetIntAttribute("index"); break; case "result": StringResult = X.GetAttribute("value"); break; case "drawreason": DrawReason = X.GetIntAttribute("value"); break; case "riichistick": RiichiStick = X.GetIntAttribute("value"); break; case "renchanstick": RenchanStick = X.GetIntAttribute("value"); break; case "balancebefore": BalanceBefore = X.ReadIntArray(); break; case "balanceafter": BalanceAfter = X.ReadIntArray(); break; case "pay": Pay = X.ReadIntArray(); break; case "winner": Winner = X.ReadBoolArray(); break; case "loser": Loser = X.ReadBoolArray(); break; case "openedsets": OpenedSets = X.ReadIntArray(); break; case "naki": Naki = X.ReadIntArray(); break; case "riichi": Riichi = X.ReadIntArray(); break; case "dealer": Dealer = X.ReadBoolArray(); break; case "tempai": Tempai = X.ReadBoolArray(); break; case "wind": Wind = X.ReadIntArray(); break; case "stepcount": StepCount = X.ReadIntArray(); break; case "firstdora": FirstDora = X.GetIntAttribute("pointer"); break; case "wall": { if (Wall == null) Wall = new Mahjong.Wall(); Wall.Dice = DecompositeIntList(X.GetAttribute("dice")); Wall.Tiles = DecompositeIntList(X.GetAttribute("tiles")); } break; case "steps": { int Count = X.GetIntAttribute("count"); XmlLoad Subtree = X.GetSubtree(); for (int j = 0; j < Count; j++) { Step NewStep = new Step(-1); NewStep.ReadXml(Subtree); Steps.Add(NewStep); } Subtree.Close(); } break; case "hands": { XmlLoad Subtree = X.GetSubtree(); while (Subtree.Read()) { switch (Subtree.ElementName) { case "hand": { int Player = Subtree.GetIntAttribute("player"); XmlLoad HandData = Subtree.GetSubtree(); StartHands[Player] = new Hand(); StartHands[Player].ReadXml(HandData); HandData.Close(); } break; } } Subtree.Close(); } break; case "shantenlist": { XmlLoad Subtree = X.GetSubtree(); while (Subtree.Read()) { switch (Subtree.ElementName) { case "shanten": { int Player = Subtree.GetIntAttribute("player"); int Count = Subtree.GetIntAttribute("shanten"); XmlLoad ShantenData = Subtree.GetSubtree(); while (ShantenData.Read()) { switch (ShantenData.ElementName) { case "step": { int Value = ShantenData.GetIntAttribute("value"); Shanten[Player].Add(Value); } break; } } ShantenData.Close(); } break; } } Subtree.Close(); } break; case "agari": { int Player = X.GetIntAttribute("player"); HanCount[Player] = X.GetIntAttribute("han"); FuCount[Player] = X.GetIntAttribute("fu"); Cost[Player] = X.GetIntAttribute("cost"); XmlLoad Subtree = X.GetSubtree(); while (Subtree.Read()) { switch (Subtree.ElementName) { case "yakulist": { int Count = Subtree.GetIntAttribute("count"); XmlLoad YakuList = Subtree.GetSubtree(); while (YakuList.Read()) { switch (YakuList.ElementName) { case "yaku": Yaku Y = new Yaku(); Y.Cost = YakuList.GetIntAttribute("cost"); Y.Index = YakuList.GetIntAttribute("index"); Yaku[Player].Add(Y); break; } } YakuList.Close(); } break; case "waitings": { int Count = Subtree.GetIntAttribute("count"); XmlLoad WaitList = Subtree.GetSubtree(); while (WaitList.Read()) { switch (WaitList.ElementName) { case "waiting": WinWaiting[Player].Add(WaitList.GetIntAttribute("value")); break; } } WaitList.Close(); } break; } } Subtree.Close(); } break; case "dora": { int Count = X.GetIntAttribute("count"); Dora.Clear(); XmlLoad Doras = X.GetSubtree(); while (Doras.Read()) { switch (Doras.ElementName) { case "dora": Dora.Add(Doras.GetIntAttribute("pointer")); break; } } Doras.Close(); } break; case "uradora": { int Count = X.GetIntAttribute("count"); UraDora.Clear(); XmlLoad Doras = X.GetSubtree(); while (Doras.Read()) { switch (Doras.ElementName) { case "dora": UraDora.Add(Doras.GetIntAttribute("pointer")); break; } } Doras.Close(); } break; } } }
public void CreateLobby(LobbyType lobbyType, int maxMembers) { CheckIfUsable(); NativeMethods.MatchMaking_CreateLobby((int)lobbyType, maxMembers); }
public TypedLobby(string name, LobbyType type) { this.Name = name; this.Type = type; }
public bool SetLobbyType(SteamID steamIDLobby, LobbyType lobbyType) { CheckIfUsable(); return NativeMethods.MatchMaking_SetLobbyType(steamIDLobby.AsUInt64, (int)lobbyType); }
public BaseLobby(LobbyType type) { Type = type; }
/// <summary> /// Gets match details for a single match, this includes player builds and details. Requires "MatchClass". /// </summary> public static MatchDetailsModel GetMatchDetail(long matchid) { string response = DownloadSteamAPIString(MATCHDETAILSURL, API + "&match_id=" + matchid); var detail = JsonConvert.DeserializeObject <MatchDetailsRootObject>(response); MatchDetailsModel match = detail.Result; #region MetaData if (LobbyType.TryGetValue(match.Lobby_Type, out string lobby)) { match.Lobbytype = lobby; } if (GameModes.TryGetValue(match.Game_Mode, out string mode)) { match.Game_ModeStr = mode; } match.StartTime = StringManipulation.UnixTimeStampToDateTime(match.Start_Time); string playedTimeAgo = ""; if ((DateTime.Now - match.StartTime).TotalDays < 1) { playedTimeAgo = Math.Ceiling((DateTime.Now - match.StartTime).TotalHours).ToString() + " hours ago"; } else { playedTimeAgo = Math.Ceiling((DateTime.Now - match.StartTime).TotalDays).ToString() + " days ago"; } match.PlayedTimeAgo = playedTimeAgo; TimeSpan timeToConvert = TimeSpan.FromSeconds(match.Duration); match.DurationStr = timeToConvert.ToString(@"mm\:ss"); timeToConvert = TimeSpan.FromSeconds(match.First_Blood_Time); match.First_Blood_TimeStr = timeToConvert.ToString(@"mm\:ss"); timeToConvert = TimeSpan.FromSeconds(match.Start_Time); match.Start_TimeStr = match.StartTime.ToString(@"dd MMM yyyy HH\:mm\:ss"); #endregion #region PlayerInfo foreach (var player in match.Players) { player.Name = ConvertIDtoName(player.Hero_ID, Heroes); player.HeroImage = ConvertIDtoImageUrl(player.Hero_ID, Heroes); player.Steamid64 = StringManipulation.SteamIDConverter(player.Account_ID); player.Steamid32 = StringManipulation.SteamIDConverter64to32(player.Steamid64); SteamAccountPlayerModel steamaccount = GetSteamAccount(player.Account_ID); player.PlayerName = string.IsNullOrEmpty(steamaccount.PersonaName) ? "Anonymous" : steamaccount.PersonaName; player.Tower_Damage = player.Tower_Damage == 0 ? 0 : player.Tower_Damage; // getting item names based on the id number player.Item0 = player.Item_0 > 0 ? ConvertIDtoName(player.Item_0, Items) : null; player.Item0Image = player.Item_0 > 0 ? ConvertIDtoImageUrl(player.Item_0, Items) : BLANKIMG; player.Item1 = player.Item_1 > 0 ? ConvertIDtoName(player.Item_1, Items) : null; player.Item1Image = player.Item_1 > 0 ? ConvertIDtoImageUrl(player.Item_1, Items) : BLANKIMG; player.Item2 = player.Item_2 > 0 ? ConvertIDtoName(player.Item_2, Items) : null; player.Item2Image = player.Item_2 > 0 ? ConvertIDtoImageUrl(player.Item_2, Items) : BLANKIMG; player.Item3 = player.Item_3 > 0 ? ConvertIDtoName(player.Item_3, Items) : null; player.Item3Image = player.Item_3 > 0 ? ConvertIDtoImageUrl(player.Item_3, Items) : BLANKIMG; player.Item4 = player.Item_4 > 0 ? ConvertIDtoName(player.Item_4, Items) : null; player.Item4Image = player.Item_4 > 0 ? ConvertIDtoImageUrl(player.Item_4, Items) : BLANKIMG; player.Item5 = player.Item_5 > 0 ? ConvertIDtoName(player.Item_5, Items) : null; player.Item5Image = player.Item_5 > 0 ? ConvertIDtoImageUrl(player.Item_5, Items) : BLANKIMG; player.Backpack0 = player.Backpack_0 > 0 ? ConvertIDtoName(player.Backpack_0, Items) : null; player.Backpack0Image = player.Backpack_0 > 0 ? ConvertIDtoImageUrl(player.Backpack_0, Items) : BLANKIMG; player.Backpack1 = player.Backpack_1 > 0 ? ConvertIDtoName(player.Backpack_1, Items) : null; player.Backpack1Image = player.Backpack_1 > 0 ? ConvertIDtoImageUrl(player.Backpack_1, Items) : BLANKIMG; player.Backpack2 = player.Backpack_2 > 0 ? ConvertIDtoName(player.Backpack_2, Items) : null; player.Backpack2Image = player.Backpack_2 > 0 ? ConvertIDtoImageUrl(player.Backpack_2, Items) : BLANKIMG; if (player.Ability_Upgrades != null) { foreach (var ability in player.Ability_Upgrades) { // clean up the object a bit and put // id where it should be. ability.ID = ability.Ability; // map the id to a readable name. ability.Name = ConvertIDtoName(Convert.ToInt32(ability.Ability), Abilities); // add the upgrade seconds to the original start // time to get the upgrade time. ability.UpgradeTime = match.StartTime.AddSeconds(ability.Time); } } else { // sb.AppendLine("No abilities data"); } } #endregion return(match); }
// bool public bool SetLobbyType(CSteamID steamIDLobby /*class CSteamID*/, LobbyType eLobbyType /*ELobbyType*/) { return(platform.ISteamMatchmaking_SetLobbyType(steamIDLobby.Value, eLobbyType)); }
public static void StartAllegiance(string ticket, LobbyType lobbyType, string alias, TaskDelegate onCompleteDelegate) { DebugDetector.AssertCheckRunning(); TaskHandler.RunTask(delegate(object p) { var param = p as object[]; var sessionTicket = param[0] as string; var signal = param[1] as TaskDelegate; var succeeded = false; try { AllegianceRegistry.OutputDebugString = DataStore.Preferences.DebugLog; AllegianceRegistry.LogToFile = DataStore.Preferences.DebugLog; AllegianceRegistry.LogChat = DataStore.Preferences.LogChat; //Create commandline var commandLine = new StringBuilder("-authenticated") .AppendFormat(" -callsign={0}", alias); if (DataStore.Preferences.DebugLog) { commandLine.Append(" -debug"); } if (DataStore.Preferences.LaunchWindowed) { commandLine.Append(" -windowed"); } if (DataStore.Preferences.NoMovies) { commandLine.Append(" -nomovies"); } //Start Allegiance string lobbyPath = Path.Combine(AllegianceRegistry.LobbyPath, lobbyType.ToString()); string allegiancePath = Path.Combine(lobbyPath, "Allegiance.exe"); if (DataStore.Preferences.UseDX7Engine == true) { allegiancePath = Path.Combine(lobbyPath, "AllegianceDX7.exe"); } #if DEBUG if (String.IsNullOrEmpty(ConfigurationManager.AppSettings["AllegianceExeOverride"]) == false) { Log.Write("Allegiance path was overridden by configuration setting."); allegiancePath = ConfigurationManager.AppSettings["AllegianceExeOverride"]; } #endif Log.Write("Using: " + allegiancePath + " " + commandLine.ToString() + " to launch..."); ProcessHandler process = ProcessHandler.Start(allegiancePath, commandLine.ToString()); process.OnExiting += new EventHandler(process_OnExiting); _allegianceProcess = process; _allegianceProcessMonitor = new ProcessMonitor(_allegianceProcess); // If launching into a lobby, then relay the security token to the allegiance process. if (lobbyType != LobbyType.None) { //Open Pipe using (var reset = new ManualResetEvent(false)) { TaskHandler.RunTask(delegate(object value) { var parameters = value as object[]; var localProcessHandler = parameters[0] as ProcessHandler; var localSessionTicket = parameters[1] as String; var localReset = parameters[2] as ManualResetEvent; using (var pipe = new Pipe(@"\\.\pipe\allegqueue")) { pipe.Create(); if (pipe.Connect()) { Int64 memoryLocation = Int64.Parse(pipe.Read()); localProcessHandler.WriteMemory(memoryLocation, localSessionTicket + (char)0x00 + Process.GetCurrentProcess().Id); localReset.Set(); } } }, process, sessionTicket, reset); //Wait X seconds, if allegiance does not retrieve the ticket, exit Allegiance. if (!reset.WaitOne(PipeTimeout)) { try { process.ForceClose(); //Connect to the pipe in order to close out the connector thread. using (var pipe = new Pipe(@"\\.\pipe\allegqueue")) { pipe.OpenExisting(); pipe.Read(); } } catch { } finally { throw new Exception("Allegiance did not respond within the time allotted."); } } // The memory address was retrived from the pipe, write the ticket onto the target process. //process.WriteMemory((Int64) memoryLocation, sessionTicket); } } succeeded = true; } catch (Exception error) { Log.Write(error); } finally { signal(succeeded); } }, ticket, onCompleteDelegate); }
public bool OpJoinLobby(string name, LobbyType lobbyType) { TypedLobby lobby = new TypedLobby(name, lobbyType); bool sent = this.loadBalancingPeer.OpJoinLobby(lobby); if (sent) { this.CurrentLobby = lobby; } return sent; }
public bool OpJoinRandomRoom(Hashtable expectedCustomRoomProperties, byte expectedMaxPlayers, MatchmakingMode matchmakingMode, string lobbyName, LobbyType lobbyType, string sqlLobbyFilter) { return this.OpJoinRandomRoom(expectedCustomRoomProperties, expectedMaxPlayers, matchmakingMode, new TypedLobby() {Name = lobbyName, Type = lobbyType}, sqlLobbyFilter); }