public void Can_deserialize() { var rawPacket = FakePackets.Instantiate(new byte[] { 0xBF, // packet 0x00, 0x0D, // size 0x00, 0x04, // sub command 0x96, 0x00, 0x05, 0x7B, 0x00, 0x00, 0x00, 0x01 }); var packet = new CloseGenericGumpPacket(); packet.Deserialize(rawPacket); packet.GumpTypeId.Should().Be((GumpTypeId)0x9600057B); }
private Packet?FilterSendGumpMenuDialog(Packet rawPacket) { if (rawPacket.Id == PacketDefinitions.GeneralInformationPacket.Id && rawPacket.Payload[4] == 4) { var packet = new CloseGenericGumpPacket(); packet.Deserialize(rawPacket); eventSource.Publish(new ServerRequestedGumpCloseEvent(packet.GumpTypeId)); } if (rawPacket.Id == PacketDefinitions.SendGumpMenuDialog.Id) { var nextGumpNotVisible = false; lock (gumpLock) { var packet = PacketDefinitionRegistry.Materialize <SendGumpMenuDialogPacket>(rawPacket); var gump = new Gump(packet.GumpId, packet.GumpTypeId, packet.Commands, packet.TextLines); CurrentGump = gump; eventSource.Publish(new GumpReceivedEvent(gump)); if (!showNextAwaitedGump) { currentGumpVisible = false; nextGumpNotVisible = true; showNextAwaitedGump = true; } else { currentGumpVisible = true; } } gumpReceivedEvent.Set(); if (nextGumpNotVisible) { return(null); } } return(rawPacket); }
private Packet?FilterSendGumpMenuDialog(Packet rawPacket) { if (rawPacket.Id == PacketDefinitions.GeneralInformationPacket.Id && rawPacket.Payload[4] == 4) { var packet = new CloseGenericGumpPacket(); packet.Deserialize(rawPacket); eventSource.Publish(new ServerRequestedGumpCloseEvent(packet.GumpTypeId)); } else if (rawPacket.Id == PacketDefinitions.SendGumpMenuDialog.Id) { bool discard = HandleGump(() => { var packet = packetRegistry.Materialize <SendGumpMenuDialogPacket>(rawPacket); return(new Gump(packet.GumpId, packet.GumpTypeId, packet.Commands, packet.TextLines)); }); if (discard) { return(null); } } else if (rawPacket.Id == PacketDefinitions.CompressedGump.Id) { bool discard = HandleGump(() => { var packet = packetRegistry.Materialize <CompressedGumpPacket>(rawPacket); return(new Gump(packet.GumpId, packet.GumpTypeId, packet.Commands, packet.TextLines)); }); if (discard) { return(null); } } return(rawPacket); }