public void Doesnt_block_gump_response_from_client_after_closing_hidden_gump() { // 1. proxy sends the response to server // 2. proxy sends close gump request to client (General information packet 0xBF, subcommand 0x04) // 3. game client responds to 0xBF/0x04 by sending gump cancellation request to proxy // 4. proxy blocks the gump cancellation request // 5. user opens and cancells the same gump // Proxy must not block the response in this case and the observer has to reset current gump. var testProxy = new InfusionTestProxy(); var task = Task.Run(() => { testProxy.Api.WaitForGump(false); testProxy.Api.GumpResponse().Cancel(); }); testProxy.Api.WaitForGumpStartedEvent.AssertWaitOneSuccess(); testProxy.PacketReceivedFromServer(SendGumpMenuDialogPackets.Explevel); task.AssertWaitFastSuccess(); // script closes hidden gump, // but no cancellation request from game client, because there is no 0xBF/0x04 sent to the client // user opens gump from game client testProxy.PacketReceivedFromServer(SendGumpMenuDialogPackets.Explevel); // user closes gump from game client testProxy.PacketReceivedFromClient(GumpMenuSelectionRequests.CancelExplevel); testProxy.Api.CurrentGump.Should().BeNull(); }
public void Can_response_to_gump_and_receive_next_gump_from_server_before_game_client_sends_gump_cancallation_request() { // 1. proxy sends the response to the server // 2. proxy sends close gump request to the game client (General information packet 0xBF, subcommand 0x04) // 3. server sends a new gump to proxy // 3. game client responds to 0xBF/0x04 by sending gump cancellation request to proxy // 4. proxy blocks the gump cancellation request // This scenario can happen on slow computers, where server sends another gump before client responds with cancellation request // Server sends another gump after response quite frequently, e.g. crafting menus. // If proxy doesn't block the gump cancellation request then server receives a response to a gump that was already // closed by proxy (step 1) and sends unexpected response error. var testProxy = new InfusionTestProxy(); var task = Task.Run(() => { testProxy.Api.WaitForGump(); // cancellation a special case of gump response testProxy.Api.GumpResponse().Cancel(); }); testProxy.Api.WaitForGumpStartedEvent.AssertWaitOneSuccess(); testProxy.PacketReceivedFromServer(SendGumpMenuDialogPackets.Explevel); task.AssertWaitFastSuccess(); // second gump from server comes before client cancellation of the first gump // first and second gump can have same ids testProxy.PacketReceivedFromServer(SendGumpMenuDialogPackets.Explevel); // game client cancellation of the first gump (client is slower than server) testProxy.PacketReceivedFromClient(GumpMenuSelectionRequests.CancelExplevel).Should().BeNull(); }
public void AskForMobile_returns_null_When_client_cancels_target_and_some_target_was_already_selected() { var testProxy = new InfusionTestProxy(); testProxy.PacketReceivedFromClient(new Packet(0x6C, new byte[] { 0x6C, 0x00, 0xDE, 0xAD, 0xBE, 0xEF, 0x00, 0x11, 0x12, 0x13, 0x14, 0x09, 0xEC, 0x0C, 0xF9, 0x00, 0x00, 0x00, 0x00, })); var task = Task.Run(() => { testProxy.Api.AskForMobile().Should().BeNull(); }); testProxy.Api.AskForTargetStartedEvent.WaitOne(100).Should().BeTrue(); testProxy.PacketReceivedFromClient(new Packet(0x6C, new byte[] { 0x6C, 0x01, 0xDE, 0xAD, 0xBE, 0xEF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, })); task.Wait(100).Should().BeTrue(); }
public void AskForLocation_waits_for_target_from_client_When_server_have_asked_for_target_before() { var testProxy = new InfusionTestProxy(); testProxy.PacketReceivedFromClient(new Packet(0x6C, new byte[] { 0x6C, 0x00, 0xDE, 0xAD, 0xBE, 0xEF, 0x00, 0x00, 0x06, 0x39, 0x0E, 0x0A, 0x75, 0x0C, 0x92, 0x00, 0x00, 0x01, 0x90, })); var task = Task.Run(() => { testProxy.Api.AskForLocation().Value.Location.Should().Be(new Location3D(0x09EC, 0x0CF9, 0)); }); testProxy.Api.AskForTargetStartedEvent.WaitOne(100).Should().BeTrue(); testProxy.PacketReceivedFromClient(new Packet(0x6C, new byte[] { 0x6C, 0x01, 0xDE, 0xAD, 0xBE, 0xEF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x09, 0xEC, 0x0C, 0xF9, 0x00, 0x00, 0x00, 0x00, })); task.Wait(100).Should().BeTrue(); }
public void AskForLocation_returns_location_selected_on_client() { var testProxy = new InfusionTestProxy(); var task = Task.Run(() => { var result = testProxy.Api.AskForLocation(); result.HasValue.Should().BeTrue(); result.Value.Location.Should().Be(new Location3D(0x09EC, 0x0CF9, 0)); }); testProxy.Api.AskForTargetStartedEvent.WaitOne(100).Should().BeTrue(); testProxy.PacketReceivedFromClient(new Packet(0x6C, new byte[] { 0x6C, 0x01, 0xDE, 0xAD, 0xBE, 0xEF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x09, 0xEC, 0x0C, 0xF9, 0x00, 0x00, 0x00, 0x00, })); task.Wait(100).Should().BeTrue(); }
public void Info_returns_info_about_mobile_selected_on_client() { var testProxy = new InfusionTestProxy(); var task = Task.Run(() => { var result = testProxy.Api.Info(); result.HasValue.Should().BeTrue(); result.Value.Id.Should().Be((ObjectId)0x00045B2A); }); testProxy.Api.AskForTargetStartedEvent.AssertWaitOneSuccess(); testProxy.PacketReceivedFromClient(new Packet(0x6C, new byte[] { 0x6C, 0x00, 0xDE, 0xAD, 0xBE, 0xEF, 0x00, 0x00, 0x04, 0x5B, 0x2A, 0x06, 0x05, 0x04, 0xC6, 0xFF, 0x00, 0x01, 0x90, })); task.AssertWaitFastSuccess(); }
public void Can_response_to_a_gump_without_provoking_unexpected_response_error_from_server() { // 1. proxy sends the response to server // 2. proxy sends close gump request to client (General information packet 0xBF, subcommand 0x04) // 3. game client responds to 0xBF/0x04 by sending gump cancellation request to proxy // 4. proxy blocks the gump cancellation request // If proxy doesn't block the gump cancellation request then server receives a response to a gump that was already // closed by proxy (step 1) and sends unexpected response error. var testProxy = new InfusionTestProxy(); var task = Task.Run(() => { testProxy.Api.WaitForGump(); // cancellation a special case of gump response testProxy.Api.GumpResponse().Cancel(); }); testProxy.Api.WaitForGumpStartedEvent.AssertWaitOneSuccess(); testProxy.PacketReceivedFromServer(SendGumpMenuDialogPackets.Explevel); task.AssertWaitFastSuccess(); testProxy.PacketReceivedFromClient(GumpMenuSelectionRequests.CancelExplevel).Should().BeNull(); }