public void Start() { _rs28Device?.Close(); _deviceListener.DeviceDisconnected += DevicePoller_DeviceDisconnected; _deviceListener.DeviceInitialized += DevicePoller_DeviceInitialized; _deviceListener.Start(); }
private async Task <bool> ListenForDeviceAsync() { var listenTaskCompletionSource = new TaskCompletionSource <bool>(); var deviceListener = new DeviceListener(new List <FilterDeviceDefinition> { new FilterDeviceDefinition { VendorId = MockHidDevice.VendorId, ProductId = MockHidDevice.ProductId } }, 1000); deviceListener.DeviceInitialized += (a, deviceEventArgs) => { Console.WriteLine($"{deviceEventArgs.Device?.DeviceId} connected"); listenTaskCompletionSource.SetResult(true); }; deviceListener.Start(); var listenTask = listenTaskCompletionSource.Task; var timeoutTask = SimulateTimeoutAsync(listenTask, 3); var completedTask = await Task.WhenAny(new List <Task> { listenTask, timeoutTask }); return(ReferenceEquals(completedTask, timeoutTask)); }
public void StartListening() { TrezorDevice?.Dispose(); DeviceListener = new DeviceListener(_DeviceDefinitions, PollMilliseconds); DeviceListener.DeviceDisconnected += DevicePoller_DeviceDisconnected; DeviceListener.DeviceInitialized += DevicePoller_DeviceInitialized; DeviceListener.Start(); }
/// <summary> /// Placeholder. This currently does nothing but you should call this to initialize listening /// </summary> public void Start() { if (_DeviceListener != null) { return; } _DeviceListener.Start(); //TODO: Call Start on the DeviceListener when it is implemented... }
/// <summary> /// Placeholder. This currently does nothing but you should call this to initialize listening /// </summary> public void Start() { if (_DeviceListener != null) { return; } _DeviceListener = new DeviceListener(DeviceDefinitions, PollInterval); _DeviceListener.DeviceDisconnected += DevicePoller_DeviceDisconnected; _DeviceListener.DeviceInitialized += DevicePoller_DeviceInitialized; _DeviceListener.Start(); //TODO: Call Start on the DeviceListener when it is implemented... }
public async Task InitialiseAsync() { _deviceListener.Start(); var devices = await DeviceManager.Current.GetDevicesAsync(_deviceDefinitions); var bulkDevices = devices.Where(device => device.DeviceId.Contains(BulkId)).ToArray(); foreach (var device in bulkDevices) { await device.InitializeAsync(); _devices[device.DeviceId] = device; } }
public void TestListenerDeviceFactoriesNotRegisteredException() { DeviceManager.Current.DeviceFactories.Clear(); try { var deviceListner = new DeviceListener(new List <FilterDeviceDefinition>(), 1000); deviceListner.Start(); } catch (DeviceFactoriesNotRegisteredException) { return; } finally { Startup(); } throw new Exception("The call was not stopped"); }
private void cmbListenerInterface_SelectedIndexChanged(object sender, EventArgs e) { if (cmbListenerInterface.SelectedIndex == -1) { return; } _targetDeviceIndex = cmbListenerInterface.SelectedIndex; SetStatus("Starting device listener .."); _deviceListener.SwitchDevice(_devices[_targetDeviceIndex]); _deviceListener.OnPacket += delegate(HttpPacket packet) { if (RequestBuilder.Instance.IsInitialized || !(packet is HttpRequestPacket)) { var debug = HttpPacket.HttpEncoding.GetString(packet.RawCapture.Data); return; } var requestPacket = packet as HttpRequestPacket; var validServerMethods = new[] { "GetMap", "GetAlliance", "AutoRefresh", "Alliance.Refresh", "GetUserNotesList" }; if (validServerMethods.Any(m => m == requestPacket.HeaderServerMethod) == false) { return; } var requestBuilder = RequestBuilder.Instance; requestBuilder.Initialize(requestPacket); SetStatus("Request data sniffed successfully"); }; _deviceListener.Start(); SetStatus("Device listener started. Please start the game now"); }
public override async Task LoadDevicesAsync() { var legacyHid = new FilterDeviceDefinition(vendorId: LOGITECH_VENDOR_ID, usagePage: 0xFF00) .CreateWindowsHidDeviceFactory(); var modernHid = new FilterDeviceDefinition(vendorId: LOGITECH_VENDOR_ID, usagePage: 0xFF43) .CreateWindowsHidDeviceFactory(); var factories = legacyHid.Aggregate(modernHid); var deviceDefinitions = (await factories.GetConnectedDeviceDefinitionsAsync().ConfigureAwait(false)).ToList(); _LogiDevices.Clear(); _deviceListener?.Dispose(); _deviceListener = new DeviceListener(factories, 1000, null); _deviceListener.DeviceInitialized += _deviceListener_DeviceInitialized; _deviceListener.DeviceDisconnected += _deviceListener_DeviceDisconnected; _deviceListener.Start(); }
/// <summary> /// Starts the device listener that manages the connection and disconnection of devices /// </summary> public void Start(bool restart) { if (restart && _DeviceListener != null) { LedgerManagers = new ReadOnlyCollection <IManagesLedger>(new List <IManagesLedger>()); _DeviceListener.DeviceDisconnected -= DevicePoller_DeviceDisconnected; _DeviceListener.DeviceInitialized -= DevicePoller_DeviceInitialized; _DeviceListener.Dispose(); _DeviceListener = null; } if (_DeviceListener == null) { _DeviceListener = new DeviceListener(DeviceDefinitions, PollInterval) { Logger = new DebugLogger() }; _DeviceListener.DeviceDisconnected += DevicePoller_DeviceDisconnected; _DeviceListener.DeviceInitialized += DevicePoller_DeviceInitialized; _DeviceListener.Start(); } }