public IncomeLowEventsSource(ReceiverBuilder builder) { foreach (EventCodes code in Enum.GetValues(typeof(EventCodes))) { switch (code) { case EventCodes.Move: break; case EventCodes.ChatMessage: case EventCodes.ChatSay: case EventCodes.ChatWhisper: case EventCodes.SystemMessage: case EventCodes.UtilityTextMessage: case EventCodes.HealthUpdate: var eventHandler = new CustomEventHandler(code); eventHandler.OnEvent += EventHandler_OnEvent; builder.AddEventHandler(eventHandler); break; default: var eventHandler2 = new CustomEventHandler(code); eventHandler2.OnEvent += EventHandler_OnEvent; builder.AddEventHandler(eventHandler2); break; } } }
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, 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); } }
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); } }