Ejemplo n.º 1
0
        public void Connect(string deviceName)
        {
            var detector = new PortDetector();
            var ports    = detector.GetUdpPorts("Albion-Online");

            foreach (var port in ports)
            {
                _udpPorts.Add(port);
            }

            var builder = ReceiverBuilder.Create();

            IncomeLowEventsSource  = new IncomeLowEventsSource(builder);
            OutcomeLowEventsSource = new OutcomeLowEventsSource(builder);

            _receiver = builder.Build();

            _device = CaptureDeviceList.Instance.Single(d => d.Name == deviceName);
            _device.Open(DeviceMode.Promiscuous, (int)TimeSpan.FromSeconds(1).TotalMilliseconds);

            foreach (var udpPort in _udpPorts)
            {
                IPortListener portListener = new PortListener(_device, udpPort, ChannelProtocol.UDP);
                _udps.Add(portListener);
                portListener.DataCaptured += Udp_OnData;
                portListener.Connect();
            }

            _device.StartCapture();

            EventsSource = new EventsSource(IncomeLowEventsSource, BuffRepository, Avatar);
            Connected?.Invoke();
        }
Ejemplo n.º 2
0
        private static void Main(string[] args)
        {
            ReceiverBuilder builder = ReceiverBuilder.Create();

            builder.AddRequestHandler(new MoveRequestHandler());
            builder.AddEventHandler(new MoveEventHandler());
            builder.AddEventHandler(new NewCharacterEventHandler());

            receiver = builder.Build();

            Console.WriteLine("Start");

            CaptureDeviceList devices = CaptureDeviceList.Instance;

            foreach (var device in devices)
            {
                new Thread(() =>
                {
                    Console.WriteLine($"Open... {device.Description}");

                    device.OnPacketArrival += new PacketArrivalEventHandler(PacketHandler);
                    device.Open(DeviceMode.Promiscuous, 1000);
                    device.StartCapture();
                })
                .Start();
            }

            Console.Read();
        }
        public static bool StartNetworkCapture(MainWindowViewModel mainWindowViewModel, TrackingController trackingController)
        {
            try
            {
                _mainWindowViewModel = mainWindowViewModel;
                builder = ReceiverBuilder.Create();

                //builder.AddResponseHandler(new UseLootChestEventHandler(trackingController));
                builder.AddEventHandler(new NewSimpleItemEventHandler(trackingController));
                builder.AddEventHandler(new NewEquipmentItemEventHandler(trackingController));
                builder.AddEventHandler(new OtherGrabbedLootEventHandler(trackingController));
                builder.AddEventHandler(new InventoryDeleteItemEventHandler(trackingController));
                builder.AddEventHandler(new InventoryPutItemEventHandler(trackingController));
                builder.AddEventHandler(new TakeSilverEventHandler(trackingController));
                builder.AddEventHandler(new UpdateFameEventHandler(trackingController));
                builder.AddEventHandler(new UpdateMoneyEventHandler(trackingController));
                builder.AddEventHandler(new UpdateReSpecPointsEventHandler(trackingController));
                builder.AddEventHandler(new UpdateCurrencyEventHandler(trackingController));
                builder.AddEventHandler(new DiedEventHandler(trackingController));
                builder.AddEventHandler(new NewLootChestEventHandler(trackingController));
                builder.AddEventHandler(new LootChestOpenedEventHandler(trackingController));
                builder.AddEventHandler(new InCombatStateUpdateEventHandler(trackingController));
                builder.AddEventHandler(new NewShrineEventHandler(trackingController));
                builder.AddRequestHandler(new UseShrineEventHandler(trackingController));
                builder.AddResponseHandler(new ChangeClusterResponseHandler(trackingController));
                builder.AddEventHandler(new HealthUpdateEventHandler(trackingController));
                builder.AddEventHandler(new PartyDisbandedEventHandler(trackingController));
                builder.AddEventHandler(new PartyChangedOrderEventHandler(trackingController));
                builder.AddResponseHandler(new PartyMakeLeaderEventHandler(trackingController));
                builder.AddEventHandler(new NewCharacterEventHandler(trackingController));
                builder.AddEventHandler(new SiegeCampClaimStartEventHandler(trackingController));
                builder.AddEventHandler(new NewMobEventHandler(trackingController));
                builder.AddEventHandler(new LeaveEventHandler(trackingController));
                builder.AddEventHandler(new CharacterEquipmentChangedEventHandler(trackingController));
                builder.AddEventHandler(new ActiveSpellEffectsUpdateEventHandler(trackingController));
                builder.AddEventHandler(new PartySilverGainedEventHandler(trackingController));
                builder.AddEventHandler(new UpdateFactionStandingEventHandler(trackingController));

                //builder.AddResponseHandler(new TestHandler());
                //builder.AddEventHandler(new TestHandler2());
                //builder.AddRequestHandler(new TestHandler3());

                builder.AddResponseHandler(new JoinResponseHandler(trackingController, _mainWindowViewModel));

                _receiver = builder.Build();

                _capturedDevices.AddRange(CaptureDeviceList.Instance);
                return(StartDeviceCapture());
            }
            catch (Exception e)
            {
                ConsoleManager.WriteLineForError(MethodBase.GetCurrentMethod().DeclaringType, e);
                Log.Error(MethodBase.GetCurrentMethod().DeclaringType, e);
                _mainWindowViewModel.SetErrorBar(Visibility.Visible, LanguageController.Translation("PACKET_HANDLER_ERROR_MESSAGE"));
                _mainWindowViewModel.StopTracking();
                return(false);
            }
        }
        public static bool StartNetworkCapture(MainWindowViewModel mainWindowViewModel, TrackingController trackingController, ValueCountUpTimer valueCountUpTimerTimer)
        {
            try
            {
                _mainWindowViewModel = mainWindowViewModel;
                builder = ReceiverBuilder.Create();

                builder.AddEventHandler(new TakeSilverEventHandler());
                builder.AddEventHandler(new UpdateFameEventHandler(trackingController, valueCountUpTimerTimer.FameCountUpTimer));
                builder.AddEventHandler(new UpdateMoneyEventHandler(trackingController, valueCountUpTimerTimer.SilverCountUpTimer));
                builder.AddEventHandler(new UpdateReSpecPointsEventHandler(trackingController, valueCountUpTimerTimer.ReSpecPointsCountUpTimer));

                builder.AddEventHandler(new DiedEventHandler(trackingController));

                builder.AddEventHandler(new NewLootChestEventHandler(trackingController));
                builder.AddEventHandler(new LootChestOpenedEventHandler(trackingController));
                builder.AddEventHandler(new InCombatStateUpdateEventHandler(trackingController));
                builder.AddEventHandler(new NewShrineEventHandler(trackingController));

                builder.AddResponseHandler(new ChangeClusterResponseHandler());
                builder.AddEventHandler(new HealthUpdateEventHandler(trackingController));
                builder.AddEventHandler(new PartyDisbandedEventHandler());
                builder.AddEventHandler(new NewCharacterEventHandler());

                builder.AddEventHandler(new PartySilverGainedEventHandler());
                //builder.AddEventHandler(new NewLootEventHandler());

                //builder.AddResponseHandler(new TestHandler());
                //builder.AddEventHandler(new TestHandler2());
                //builder.AddRequestHandler(new TestHandler3());

                builder.AddResponseHandler(new JoinResponseHandler(trackingController, _mainWindowViewModel));

                _receiver = builder.Build();

                _capturedDevices.AddRange(CaptureDeviceList.Instance);
                return(StartDeviceCapture());
            }
            catch (Exception e)
            {
                Log.Error(nameof(StartDeviceCapture), e);
                _mainWindowViewModel.SetErrorBar(Visibility.Visible, LanguageController.Translation("PACKET_HANDLER_ERROR_MESSAGE"));
                _mainWindowViewModel.StopTracking();
                return(false);
            }
        }