public IMessageHandler CreateHandler(HttpContext context, CloseFunction closeFunction, SenderFunction sendFunction) { string id = PathRegex.Match(context.Request.Path.Value).Groups[1].Value; var device = inputDevices.Find(id); return(new InputDeviceFeedbackHandler(closeFunction, sendFunction, device)); }
public IMessageHandler CreateHandler(HttpContext context, CloseFunction closeFunction, SenderFunction sendFunction) { string id = PathRegex.Match(context.Request.Path.Value).Groups[1].Value; var emulatedController = emulatedControllers.Find(id); return(new EmulatedControllerFeedbackHandler(closeFunction, sendFunction, emulatedController)); }
public XboxInputRequestHandler(CloseFunction closeFunction, SenderFunction senderFunction, XboxDevice device, EmulatedControllersService emulatedControllersService, DeviceDisconnectedEventHandler disconnectedEventHandler) : base(closeFunction, senderFunction) { this.device = device; this.emulatedControllersService = emulatedControllersService; this.disconnectedEventHandler = disconnectedEventHandler; device.FeedbackEvent += FeedbackEvent; }
private async Task HandleWebSocketContextAsync(WebSocket ws, HttpContext httpContext, IWebSocketHandler handler, CancellationToken cancellationToken) { CloseFunction closeFunction = () => ws.CloseAsync(WebSocketCloseStatus.NormalClosure, "Done", CancellationToken.None); List <IMessageHandler> messageHandlers; try { messageHandlers = handler.CreateHandlers(httpContext, closeFunction, (message) => WriteStringAsync(ws, messageWriter.GetString(message), cancellationToken)); } catch (Exception e) { logger.Error(e, "Error occured while creating handlers for {0}", httpContext.Request.Path); httpContext.Response.StatusCode = 500; return; } while (ws.State == WebSocketState.Open && !cancellationToken.IsCancellationRequested) { string requestMessage = await webSocketHelper.ReadStringAsync(ws, Encoding.UTF8, cancellationToken); if (requestMessage == null) { continue; } ProcessMessage(requestMessage, messageHandlers); } if (ws.State == WebSocketState.Open) { await closeFunction(); } handler.Close(messageHandlers); }
public void Init(CloseFunction cf, ShowHideTimer shtf, RestartFunction rf, MainMenuFunction mmf) { closeFunction = cf; showHideTimer = shtf; restartFunction = rf; mainMenuFunction = mmf; }
public List <IMessageHandler> CreateHandlers(HttpContext context, CloseFunction closeFunction, SenderFunction sendFunction) { return(new List <IMessageHandler> { new DebugMessageHandler(), new MappableDeviceMessageHandler(mappableDevices, sendFunction.GetTyped <MappableDeviceFeedbackMessage>()), }); }
public PingMessageHandler(CloseFunction closeFunction, SenderFunction <PingMessage> senderFunction) { this.closeFunction = closeFunction; this.senderFunction = senderFunction; timer = new Timer(5000); timer.Elapsed += TimerElapsed; timer.Start(); }
public Task <TransactionReceipt> CloseRequestAndWaitForReceiptAsync(BigInteger amount, byte[] signature, CancellationTokenSource cancellationToken = null) { var closeFunction = new CloseFunction(); closeFunction.Amount = amount; closeFunction.Signature = signature; return(ContractHandler.SendRequestAndWaitForReceiptAsync(closeFunction, cancellationToken)); }
public Task <string> CloseRequestAsync(BigInteger amount, byte[] signature) { var closeFunction = new CloseFunction(); closeFunction.Amount = amount; closeFunction.Signature = signature; return(ContractHandler.SendRequestAsync(closeFunction)); }
public List <IMessageHandler> CreateHandlers(HttpContext context, CloseFunction closeFunction, SenderFunction sendFunction) { string deviceId = context.Request.Path.Value.Replace($"/ws/input/", ""); var device = inputDeviceManager.FindInputDevice(deviceId); if (device == null) { throw new ArgumentException(); } return(new List <IMessageHandler> { new DebugMessageHandler(), new SourceValuesMessageHandler(device, sendFunction.GetTyped <InputValuesMessage>()), }); }
public IMessageHandler CreateHandler(HttpContext context, CloseFunction closeFunction, SenderFunction sendFunction) { string emulatorName = PathRegex.Match(context.Request.Path.Value).Groups[1].Value; Emulators emulatorType = Enum.Parse <Emulators>(emulatorName); var emulator = emulatorService.FindEmulator <IDs4Emulator>(DeviceTypes.SonyDualShock4, emulatorType); var device = emulator.CreateDs4Device(); DeviceDisconnectedEventHandler disconnectedEvent = (sender, args) => closeFunction(); device.Closed += disconnectedEvent; var ip = context.Request.HttpContext.Connection.RemoteIpAddress?.ToString(); emulatedControllersService.Add(new NetworkDeviceInfo { Device = device, IPAddress = ip, DeviceType = DeviceTypes.SonyDualShock4, Emulator = emulator.Emulator, }); return(new Ds4InputRequestHandler(closeFunction, sendFunction, device, emulatedControllersService, disconnectedEvent)); }
protected MessageHandler(CloseFunction closeFunction, SenderFunction senderFunction) { this.closeFunction = closeFunction; this.senderFunction = senderFunction; pingThreadContext = ThreadCreator.CreateLoop("Ping loop", () => { try { var r = new PingRequest { Timestamp = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds(), }; senderFunction(new PingRequest { Timestamp = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds(), }); } catch (Exception ex) { logger.Warn(ex, "Ping failed, closing connection"); closeFunction(); } }, 5000).Start(); }
public List <IMessageHandler> CreateHandlers(HttpContext context, CloseFunction closeFunction, SenderFunction sendFunction) { string emulatorName = context.Request.Path.Value.Replace($"/ws/{DeviceType}/", ""); var emulator = emulatorService.FindEmulator <IDs4Emulator>(XOutput.Emulation.DeviceTypes.SonyDualShock4, emulatorName); var device = emulator.CreateDs4Device(); DeviceDisconnectedEvent disconnectedEvent = (sender, args) => closeFunction(); device.Closed += disconnectedEvent; var ip = context.Request.HttpContext.Connection.RemoteIpAddress?.ToString(); deviceInfoService.Add(new NetworkDeviceInfo { Device = device, IPAddress = ip, DeviceType = XOutput.Emulation.DeviceTypes.SonyDualShock4, Emulator = emulator.Name, }); return(new List <IMessageHandler> { new DebugMessageHandler(), new Ds4FeedbackMessageHandler(device, sendFunction.GetTyped <Ds4FeedbackMessage>()), new Ds4InputMessageHandler(device, disconnectedEvent), }); }
public Task <string> CloseRequestAsync(CloseFunction closeFunction) { return(ContractHandler.SendRequestAsync(closeFunction)); }
public InputDeviceMessageHandler(CloseFunction closeFunction, SenderFunction senderFunction, InputDevices inputDevices) : base(closeFunction, senderFunction) { this.inputDevices = inputDevices; }
public InputDeviceFeedbackHandler(CloseFunction closeFunction, SenderFunction senderFunction, InputDevice inputDevice) : base(closeFunction, senderFunction) { this.device = inputDevice; threadContext = ThreadCreator.CreateLoop($"{device.Id} input device report thread", SendFeedback, 20); threadContext.Start(); }
/// <summary> /// Initializes a new instance of the <see cref="WizardControlViewModel"/> class. /// </summary> public WizardControlViewModel() { this.Pages = new ObservableCollection <IWizardPage>(); PreviousCommand = new DelegateCommand(() => { Navigate(NavigationDirection.Backwards); //if (SelectedIndex == Pages.IndexOf(ErrorPage)) //{ // SetPage(LastActivePageIndex); //} //else //{ // var cuItem = this.Pages[SelectedIndex]; // if (CanNavigate(NavigationDirection.Backwards, cuItem)) // SetPage(GetPreviousPageIndex(SelectedIndex)); //} }); NextCommand = new DelegateCommand(() => { Navigate(NavigationDirection.Forward); }); ProcessButtonCommand = new DelegateCommand(() => { var cuItem = this.Pages[SelectedIndex]; if (cuItem.Validate()) { if (CanNavigate(NavigationDirection.Forward, cuItem)) { IsBusy = true; } Task.Run(async() => { SetPage(Pages.IndexOf(ProgressPage)); try { if (ProcessFunction != null) { var result = await ProcessFunction(); switch (result) { case WizardProcessResult.Complete: { SetPage(Pages.IndexOf(CompletePage)); } break; default: { SetPage(Pages.IndexOf(ErrorPage)); } break; } } else { SetPage(Pages.IndexOf(CompletePage)); } } catch (Exception) { } }); // IsBusy = false; } }); CompleteCommand = new DelegateCommand(() => { CloseFunction?.Invoke(); }); CancelCommand = new DelegateCommand(() => { CancelFunction?.Invoke(); }); }
public void Dispose() => CloseFunction?.Invoke();
public EmulatedControllerFeedbackHandler(CloseFunction closeFunction, SenderFunction senderFunction, IMappedController emulatedController) : base(closeFunction, senderFunction) { this.emulatedController = emulatedController; threadContext = ThreadCreator.CreateLoop($"{emulatedController.Id} input device report thread", SendFeedback, 20); }
public IMessageHandler CreateHandler(HttpContext context, CloseFunction closeFunction, SenderFunction sendFunction) { return(new InputDeviceMessageHandler(closeFunction, sendFunction, inputDevices)); }
public void Init(CloseFunction cf, RestartFunction rf, MainMenuFunction mmf) { this.closeFunction = cf; this.restartFunction = rf; this.mainMenuFunction = mmf; }
public void InitConfirmationCanvas(YesFunction yf, NoFunction nf, CloseFunction cf) { yesFunction = yf; noFunction = nf; closeFunction = cf; }
public Task <TransactionReceipt> CloseRequestAndWaitForReceiptAsync(CloseFunction closeFunction, CancellationTokenSource cancellationToken = null) { return(ContractHandler.SendRequestAndWaitForReceiptAsync(closeFunction, cancellationToken)); }