private static void AddEventCacheData(UnifiedTestClient client1, UnifiedTestClient client2, UnifiedTestClient client3, Hashtable data) { // add cached message client1.SendRequest(new OperationRequest { OperationCode = OperationCode.RaiseEvent, Parameters = new Dictionary <byte, object> { { ParameterCode.Code, (byte)1 }, { ParameterCode.Cache, (byte)EventCaching.AddToRoomCacheGlobal }, { ParameterCode.Data, data }, } }); // add cached message client1.SendRequest(new OperationRequest { OperationCode = OperationCode.RaiseEvent, Parameters = new Dictionary <byte, object> { { ParameterCode.Code, (byte)2 }, { ParameterCode.Cache, (byte)EventCaching.AddToRoomCache }, { ParameterCode.Data, null }, } }); // add cached message client2.SendRequest(new OperationRequest { OperationCode = OperationCode.RaiseEvent, Parameters = new Dictionary <byte, object> { { ParameterCode.Code, (byte)3 }, { ParameterCode.Cache, (byte)EventCaching.AddToRoomCache }, { ParameterCode.Data, data }, } }); // add cached message client3.SendRequest(new OperationRequest { OperationCode = OperationCode.RaiseEvent, Parameters = new Dictionary <byte, object> { { ParameterCode.Code, (byte)4 }, { ParameterCode.Cache, (byte)EventCaching.AddToRoomCache }, { ParameterCode.Data, data }, } }); Thread.Sleep(200); }
public void EventCache_SliceLimitExceeded() { if (this.IsOnline) { Assert.Ignore("Does not support online mode"); } UnifiedTestClient client1 = null; UnifiedTestClient client2 = null; try { var roomName = this.GenerateRandomizedRoomName(MethodBase.GetCurrentMethod().Name); client1 = this.CreateMasterClientAndAuthenticate(Player1); client2 = this.CreateMasterClientAndAuthenticate(Player2); var createGameResponse = client1.CreateGame(roomName, true, true, 4); // switch client 1 to GS this.ConnectAndAuthenticate(client1, createGameResponse.Address, client1.UserId); var createRequest = new OperationRequest { OperationCode = OperationCode.CreateGame, Parameters = new Dictionary <byte, object>() }; createRequest.Parameters.Add(ParameterCode.RoomName, createGameResponse.GameId); createRequest.Parameters.Add((byte)Operations.ParameterCode.SuppressRoomEvents, true); client1.SendRequestAndWaitForResponse(createRequest); var raiseEventOp = new OperationRequest { OperationCode = OperationCode.RaiseEvent, Parameters = new Dictionary <byte, object> { { ParameterCode.Data, new Hashtable() }, { ParameterCode.Cache, (byte)CacheOperation.SliceIncreaseIndex } } }; for (int i = 0; i < 10; ++i) { client1.SendRequest(raiseEventOp); } client1.SendRequestAndWaitForResponse(raiseEventOp, ErrorCode.InvalidOperation); this.ConnectAndAuthenticate(client2, createGameResponse.Address); client2.JoinGame(roomName); } finally { DisposeClients(client1, client2); } }
public void RoomFlags_DeleteNullPropsWrongCASTest() { UnifiedTestClient masterClient1 = null; UnifiedTestClient masterClient2 = null; try { // create game on the game server string roomName = this.GenerateRandomizedRoomName(MethodBase.GetCurrentMethod().Name); var gameProperties = new Hashtable(); gameProperties["P1"] = 1; gameProperties["P2"] = 2; gameProperties["L1"] = 1; gameProperties["L2"] = 2; gameProperties["L3"] = 3; var createGameRequest = new CreateGameRequest { GameId = roomName, RoomFlags = RoomOptionFlags.DeleteNullProps, GameProperties = gameProperties, }; masterClient1 = this.CreateMasterClientAndAuthenticate(Player1); var cgResponse = masterClient1.CreateGame(createGameRequest); this.ConnectAndAuthenticate(masterClient1, cgResponse.Address); masterClient1.CreateGame(createGameRequest); masterClient1.SendRequest(new OperationRequest() { OperationCode = OperationCode.SetProperties, Parameters = new Dictionary <byte, object> { { (byte)ParameterKey.Properties, new Hashtable { { "P1", null } } }, { (byte)ParameterKey.ExpectedValues, new Hashtable { { "P1", 12 } } }, } }); masterClient2 = this.CreateMasterClientAndAuthenticate(Player2); var joinRequest = new JoinGameRequest() { GameId = roomName, }; var jgResponse = masterClient2.JoinGame(joinRequest, ErrorCode.Ok); this.ConnectAndAuthenticate(masterClient2, jgResponse.Address); jgResponse = masterClient2.JoinGame(joinRequest); Assert.That(jgResponse.GameProperties.Contains("P1"), Is.True); masterClient1.SendRequest(new OperationRequest() { OperationCode = OperationCode.SetProperties, Parameters = new Dictionary <byte, object> { { (byte)ParameterKey.Properties, new Hashtable { { "P2", null } } }, { (byte)ParameterKey.ExpectedValues, new Hashtable { { "P2", 23 } } }, } }); masterClient2.CheckThereIsNoEvent(EventCode.PropertiesChanged, this.WaitTimeout); } finally { DisposeClients(masterClient1, masterClient2); } }
public void RoomFlags_BroadcastOnChange([Values("ToAll", "ToOthers")] string policy) { UnifiedTestClient masterClient1 = null; UnifiedTestClient masterClient2 = null; try { // create game on the game server string roomName = this.GenerateRandomizedRoomName(MethodBase.GetCurrentMethod().Name); var gameProperties = new Hashtable(); gameProperties["P1"] = 1; gameProperties["P2"] = 2; gameProperties["L1"] = 1; gameProperties["L2"] = 2; gameProperties["L3"] = 3; var createGameRequest = new CreateGameRequest { GameId = roomName, GameProperties = gameProperties, RoomFlags = policy == "ToAll" ? RoomOptionFlags.BroadcastPropsChangeToAll : 0, }; masterClient1 = this.CreateMasterClientAndAuthenticate(Player1); var cgResponse = masterClient1.CreateGame(createGameRequest); this.ConnectAndAuthenticate(masterClient1, cgResponse.Address); masterClient1.CreateGame(createGameRequest); masterClient2 = this.CreateMasterClientAndAuthenticate(Player2); var joinRequest = new JoinGameRequest() { GameId = roomName, }; var jgResponse = masterClient2.JoinGame(joinRequest, ErrorCode.Ok); this.ConnectAndAuthenticate(masterClient2, jgResponse.Address); masterClient2.JoinGame(joinRequest); masterClient1.EventQueueClear(); masterClient1.SendRequest(new OperationRequest() { OperationCode = OperationCode.SetProperties, Parameters = new Dictionary <byte, object> { { (byte)ParameterKey.Properties, new Hashtable { { "P2", 22 } } }, { (byte)ParameterKey.Broadcast, true } } }); masterClient2.CheckThereIsEvent(EventCode.PropertiesChanged, this.WaitTimeout); if (policy == "ToOthers") { masterClient1.CheckThereIsNoEvent(EventCode.PropertiesChanged, this.WaitTimeout); } else { masterClient1.CheckThereIsEvent(EventCode.PropertiesChanged, this.WaitTimeout); } } finally { DisposeClients(masterClient1, masterClient2); } }
public void EventCache_AddGlobalEventRemoveUsing0ActorId() { UnifiedTestClient client1 = null; UnifiedTestClient client2 = null; try { var roomName = this.GenerateRandomizedRoomName(MethodBase.GetCurrentMethod().Name); // create room client1 = this.CreateMasterClientAndAuthenticate(this.Player1); var createGameRequest = new CreateGameRequest { GameId = roomName, CheckUserOnJoin = !string.IsNullOrEmpty(this.Player1), }; var createGameResponse = client1.CreateGame(createGameRequest); this.ConnectAndAuthenticate(client1, createGameResponse.Address); // creation on GS client1.CreateGame(createGameRequest); var data = new Hashtable() { { (byte)7, 1 } }; // add cached message client1.SendRequest(new OperationRequest { OperationCode = OperationCode.RaiseEvent, Parameters = new Dictionary <byte, object> { { ParameterCode.Code, (byte)1 }, { ParameterCode.Data, data }, { ParameterCode.Cache, (byte)EventCaching.AddToRoomCacheGlobal }, } }); // remove cached message client1.SendRequest(new OperationRequest { OperationCode = OperationCode.RaiseEvent, Parameters = new Dictionary <byte, object> { { ParameterCode.Code, (byte)1 }, { ParameterCode.ActorList, new int[] { 0 } }, { ParameterCode.Data, data }, { ParameterCode.Cache, (byte)EventCaching.RemoveFromRoomCache }, } }); // second player joins and check that there is no removed event client2 = this.CreateMasterClientAndAuthenticate(this.Player2); this.ConnectClientToGame(client2, roomName); client2.WaitForEvent(EventCode.Join); client2.CheckThereIsNoEvent(1); } finally { DisposeClients(client1, client2); } }
public void EventCache_ActorCacheLimitExceeded() { if (this.IsOnline) { Assert.Ignore("Does not support online mode"); } UnifiedTestClient client1 = null; UnifiedTestClient client2 = null; UnifiedTestClient client3 = null; try { var roomName = this.GenerateRandomizedRoomName(MethodBase.GetCurrentMethod().Name); client1 = this.CreateMasterClientAndAuthenticate(Player1); client3 = this.CreateMasterClientAndAuthenticate(Player3); var createGameResponse = client1.CreateGame(roomName, true, true, 4); // switch client 1 to GS this.ConnectAndAuthenticate(client1, createGameResponse.Address); this.ConnectAndAuthenticate(client3, createGameResponse.Address); client1.CreateGame(new CreateGameRequest() { GameId = roomName, PlayerTTL = -1, SuppressRoomEvents = true, CheckUserOnJoin = true }); client3.JoinGame(roomName); // exceeding limits for (byte i = 1; i <= 11; ++i) { var raiseEventOp = new OperationRequest { OperationCode = OperationCode.RaiseEvent, Parameters = new Dictionary <byte, object> { { ParameterCode.Data, new Hashtable() }, { ParameterCode.Cache, (byte)CacheOperation.MergeCache }, { ParameterCode.Code, i } } }; client1.SendRequest(raiseEventOp); } client1.WaitForEvent(EventCode.PropertiesChanged); client1.WaitForEvent(EventCode.ErrorInfo); client2 = this.CreateMasterClientAndAuthenticate(Player2); client2.JoinGame(roomName, ErrorCode.GameClosed); this.ConnectAndAuthenticate(client2, createGameResponse.Address); client2.JoinGame(roomName, ErrorCode.GameClosed); client3.LeaveGame(true); client3.Disconnect(); this.ConnectAndAuthenticate(client3, createGameResponse.Address); client3.JoinGame(new JoinGameRequest { GameId = roomName, JoinMode = JoinModes.RejoinOnly }, 32739);//EventCacheExceeded } finally { DisposeClients(client1, client2, client3); } }
public void EventCache_RemoveUsingActorIdAndEventCode() { UnifiedTestClient client1 = null; UnifiedTestClient client2 = null; UnifiedTestClient client3 = null; UnifiedTestClient client4 = null; try { var roomName = this.GenerateRandomizedRoomName(MethodBase.GetCurrentMethod().Name); // create room client1 = this.CreateMasterClientAndAuthenticate(this.Player1); var createGameRequest = new CreateGameRequest { GameId = roomName, CheckUserOnJoin = !string.IsNullOrEmpty(this.Player1), }; var createGameResponse = client1.CreateGame(createGameRequest); this.ConnectAndAuthenticate(client1, createGameResponse.Address); // creation on GS client1.CreateGame(createGameRequest); // second player joins and check that there is no removed event client2 = this.CreateMasterClientAndAuthenticate(this.Player2); client3 = this.CreateMasterClientAndAuthenticate(this.Player3); this.ConnectClientToGame(client2, roomName); this.ConnectClientToGame(client3, roomName); var eventsData = new Hashtable { { 1, 1 } }; AddEventCacheData(client1, client2, client3, eventsData); client2.Disconnect(); client3.Disconnect(); // remove cached message client1.SendRequest(new OperationRequest { OperationCode = OperationCode.RaiseEvent, Parameters = new Dictionary <byte, object> { { ParameterCode.ActorList, new int[] { 3 } }, { ParameterCode.Cache, (byte)EventCaching.RemoveFromRoomCache }, { ParameterCode.Code, (byte)4 }, } }); client4 = this.CreateMasterClientAndAuthenticate("Player4"); this.ConnectClientToGame(client4, roomName); client4.WaitForEvent(EventCode.Join); client4.CheckThereIsEvent(1); client4.CheckThereIsEvent(2); client4.CheckThereIsEvent(3); client4.CheckThereIsNoEvent(4); } finally { DisposeClients(client1, client2, client3, client4); } }
public void EventCache_ActorReplaceData() { UnifiedTestClient client1 = null; UnifiedTestClient client2 = null; UnifiedTestClient client3 = null; UnifiedTestClient client4 = null; try { var roomName = this.GenerateRandomizedRoomName(MethodBase.GetCurrentMethod().Name); // create room client1 = this.CreateMasterClientAndAuthenticate(this.Player1); var createGameRequest = new CreateGameRequest { GameId = roomName, CheckUserOnJoin = !string.IsNullOrEmpty(this.Player1), }; var createGameResponse = client1.CreateGame(createGameRequest); this.ConnectAndAuthenticate(client1, createGameResponse.Address); // creation on GS client1.CreateGame(createGameRequest); // second player joins and check that there is no removed event client2 = this.CreateMasterClientAndAuthenticate(this.Player2); client3 = this.CreateMasterClientAndAuthenticate(this.Player3); this.ConnectClientToGame(client2, roomName); this.ConnectClientToGame(client3, roomName); var eventsData = new Hashtable { { 1, 1 } }; var eventsData2 = new Hashtable { { 2, 2 } }; AddActorEventCacheData(client1, client2, client3, eventsData); client2.Disconnect(); client3.Disconnect(); // update cached message client1.SendRequest(new OperationRequest { OperationCode = OperationCode.RaiseEvent, Parameters = new Dictionary <byte, object> { { ParameterCode.Data, eventsData2 }, { ParameterCode.Cache, (byte)EventCaching.ReplaceCache }, { ParameterCode.Code, (byte)1 }, } }); client4 = this.CreateMasterClientAndAuthenticate("Player4"); this.ConnectClientToGame(client4, roomName); client4.WaitForEvent(EventCode.Join); EventData ev; Assert.That(client4.TryWaitEvent(1, this.WaitTimeout, out ev), Is.True); Assert.That(ev[(byte)ParameterKey.Data], Is.EqualTo(eventsData2)); client4.CheckThereIsEvent(2); client4.CheckThereIsEvent(3); } finally { DisposeClients(client1, client2, client3, client4); } }
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); } }
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 void SecureParamsTest() { UnifiedTestClient client = null; UnifiedTestClient client2 = null; const int SleepTime = 350; try { client = (UnifiedTestClient)this.CreateTestClient(); client.UserId = Player1; this.ConnectToServer(client, this.MasterAddress); var response = client.Authenticate(Player1, new Dictionary <byte, object>() { { (byte)ParameterKey.ClientAuthenticationParams, "username=yes&token=yes" } }); Assert.AreEqual("nick", response[(byte)ParameterKey.Nickname]); Assert.IsNotNull(response[(byte)ParameterKey.Token]); var request = new OperationRequest { OperationCode = OperationCode.CreateGame, Parameters = new Dictionary <byte, object> { { ParameterCode.RoomName, "TestGame" }, { ParameterCode.Plugins, new string[] { "CheckSecurePlugin" } }, } }; response = client.SendRequestAndWaitForResponse(request); this.ConnectAndAuthenticate(client, (string)response[ParameterCode.Address], client.UserId, new Dictionary <byte, object>() { { (byte)ParameterKey.ClientAuthenticationParams, "username=yes&token=yes" } }); client.SendRequestAndWaitForResponse(request); Thread.Sleep(SleepTime); CheckSecure("CreateGameAuthCookie"); client2 = this.CreateMasterClientAndAuthenticate("User2", new Dictionary <byte, object>() { { (byte)ParameterKey.ClientAuthenticationParams, "username=yes&token=yes" } }); request = new OperationRequest { OperationCode = OperationCode.JoinGame, Parameters = new Dictionary <byte, object> { { ParameterCode.RoomName, "TestGame" }, } }; response = client2.SendRequestAndWaitForResponse(request); this.ConnectAndAuthenticate(client2, (string)response[ParameterCode.Address], client2.UserId, new Dictionary <byte, object>() { { (byte)ParameterKey.ClientAuthenticationParams, "username=yes&token=yes" } }); client2.SendRequestAndWaitForResponse(request); Thread.Sleep(SleepTime); CheckSecure("JoinGameAuthCookie"); request = new OperationRequest { OperationCode = OperationCode.RaiseEvent, Parameters = new Dictionary <byte, object> { { ParameterCode.Code, (byte)1 }, { ParameterCode.EventForward, (byte)3 }, } }; client2.SendRequest(request); Thread.Sleep(SleepTime); CheckSecure("RaiseEventAuthCookie"); //just to ensure that there is nothing on server for RaiseEventAuthCookie CheckSecure("RaiseEventAuthCookie", expectToFail: true); request = new OperationRequest { OperationCode = OperationCode.RaiseEvent, Parameters = new Dictionary <byte, object> { { ParameterCode.Code, (byte)1 }, { ParameterCode.EventForward, (byte)1 },// we send request but without secure } }; client2.SendRequest(request); CheckSecure("RaiseEventAuthCookie", expectToFail: true); client.SendRequestAndWaitForResponse(new OperationRequest { OperationCode = OperationCode.SetProperties, Parameters = new Dictionary <byte, object> { { ParameterCode.Properties, new Hashtable { { GamePropertyKey.IsOpen, true } } }, { ParameterCode.EventForward, (byte)3 }, } }); Thread.Sleep(SleepTime); CheckSecure("SetPropertiesAuthCookie"); client.SendRequestAndWaitForResponse(new OperationRequest { OperationCode = OperationCode.WebRpc, Parameters = new Dictionary <byte, object> { { ParameterCode.Data, new Hashtable { { GamePropertyKey.IsOpen, true } } }, { ParameterCode.EventForward, (byte)3 }, { ParameterCode.UriPath, "RpcSecure" }, } }); Thread.Sleep(SleepTime); CheckSecure("RpcAuthCookie"); client.SendRequestAndWaitForResponse(new OperationRequest { OperationCode = OperationCode.WebRpc, Parameters = new Dictionary <byte, object> { { ParameterCode.Data, new Hashtable { { GamePropertyKey.IsOpen, true } } }, { ParameterCode.UriPath, "RpcSecure" }, } }); Thread.Sleep(SleepTime); CheckSecure("RpcAuthCookie", true); var client3 = this.CreateMasterClientAndAuthenticate("User3", new Dictionary <byte, object>() { { (byte)ParameterKey.ClientAuthenticationParams, "username=yes&token=yes" } }); client3.SendRequestAndWaitForResponse(new OperationRequest { OperationCode = OperationCode.WebRpc, Parameters = new Dictionary <byte, object> { { ParameterCode.Data, new Hashtable { { GamePropertyKey.IsOpen, true } } }, { ParameterCode.UriPath, "RpcSecure" }, { ParameterCode.EventForward, (byte)3 }, } }); Thread.Sleep(SleepTime); CheckSecure("RpcAuthCookie"); client3.SendRequestAndWaitForResponse(new OperationRequest { OperationCode = OperationCode.WebRpc, Parameters = new Dictionary <byte, object> { { ParameterCode.Data, new Hashtable { { GamePropertyKey.IsOpen, true } } }, { ParameterCode.UriPath, "RpcSecure" }, { ParameterCode.EventForward, (byte)1 }, } }); Thread.Sleep(SleepTime); CheckSecure("RpcAuthCookie", expectToFail: true); } finally { DisposeClients(client, client2); } }
public void A_Group_PluginHttpCallSyncAfterContinueTests() { const string config = "HttpCallSyncAfterContinue"; UnifiedTestClient client = null; UnifiedTestClient client2 = null; var GameName = RandomizeString(MethodBase.GetCurrentMethod().Name); try { client = this.CreateMasterClientAndAuthenticate("User1"); var request = new OperationRequest { OperationCode = OperationCode.CreateGame, Parameters = new Dictionary <byte, object> { { ParameterCode.RoomName, GameName }, { ParameterCode.EmptyRoomTTL, 0 }, { ParameterCode.PlayerTTL, 0 }, { ParameterCode.CheckUserOnJoin, false }, { ParameterCode.CleanupCacheOnLeave, false }, { ParameterCode.SuppressRoomEvents, false }, { ParameterCode.LobbyName, "Default" }, { ParameterCode.LobbyType, (byte)0 }, { ParameterCode.GameProperties, new Hashtable { { "config", config } } }, { ParameterCode.Plugins, new string[] { "AllMethosCallHttpTestPlugin" } }, } }; var response = client.SendRequestAndWaitForResponse(request); this.ConnectAndAuthenticate(client, (string)response[ParameterCode.Address], client.UserId); client.SendRequestAndWaitForResponse(request); client.CheckThereIsEvent(123, this.WaitTimeout); client.SendRequestAndWaitForResponse(new OperationRequest { OperationCode = OperationCode.SetProperties, Parameters = new Dictionary <byte, object> { { ParameterCode.Properties, new Hashtable { { GamePropertyKey.IsOpen, true } } } } }); client.CheckThereIsErrorInfoEvent(this.WaitTimeout); client.CheckThereIsEvent(123, this.WaitTimeout); request = new OperationRequest { OperationCode = OperationCode.JoinGame, Parameters = new Dictionary <byte, object> { { ParameterCode.RoomName, GameName }, { ParameterCode.PlayerProperties, new Hashtable { { "Actor2Property", "Actor2PropertyValue" } } }, { ParameterCode.GameProperties, new Hashtable() }, { ParameterCode.UserId, "User2" }, { ParameterCode.LobbyName, "Default" }, }, }; client2 = this.CreateMasterClientAndAuthenticate("User2"); response = client2.SendRequestAndWaitForResponse(request); this.ConnectAndAuthenticate(client2, (string)response[ParameterCode.Address], client2.UserId); client2.SendRequestAndWaitForResponse(request); client.CheckThereIsErrorInfoEvent(this.WaitTimeout); client.CheckThereIsEvent(123, this.WaitTimeout); request = new OperationRequest { OperationCode = OperationCode.RaiseEvent, Parameters = new Dictionary <byte, object> { { ParameterCode.Code, (byte)1 }, } }; client.SendRequest(request); client.CheckThereIsEvent(123, this.WaitTimeout); client2.SendRequestAndWaitForResponse(new OperationRequest { OperationCode = OperationCode.Leave, Parameters = new Dictionary <byte, object> { { ParameterCode.IsInactive, true } } }); client2.Disconnect(); client.CheckThereIsNoErrorInfoEvent(); client.Disconnect(); } finally { if (client != null && client.Connected) { client.Disconnect(); client.Dispose(); } if (client2 != null && client2.Connected) { client2.Disconnect(); client2.Dispose(); } this.CheckGameIsClosed(GameName, this.WaitTimeout); } }