/// <summary> /// Receives message from UWP app and sends a response back /// </summary> public void OnAppServiceConnectionRequestReceived( AppServiceConnection sender, AppServiceRequestReceivedEventArgs args) { string requestKey = args.Request.Message.First().Key; string requestValue = args.Request.Message.First().Value.ToString(); Logger.Log(string.Format("Received request '{0}' with value '{1}'", requestKey, requestValue), ConsoleColor.Magenta); ValueSet valueSet = new ValueSet(); if (requestKey.Equals(Keys.KeyGeneralRequest)) { // Just echo the request value valueSet.Add(requestKey, requestValue); } else if (requestKey.Equals(Keys.KeyProcessDetailsByWindowHandleRequest)) { string responseValue = ProcessUtils.ProcessProxyByMainWindowHandle(int.Parse(requestValue)).ToJson().ToString(); valueSet.Add(requestKey, responseValue); } Logger.Log(string.Format("Responding to request '{0}' with value '{1}'", requestKey, valueSet.First().Value.ToString()), ConsoleColor.Magenta); args.Request.SendResponseAsync(valueSet).Completed += delegate { }; }
private async void ConnectionOnMessageReceived(ValueSet valueSet) { await Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () => { var message = valueSet.First(); MessageResults.Text = $"{message.Value}"; }); }
private async Task <string> SelectSingleAccountIdByWindowTitle(string windowTitle, IntPtr hWnd) { ValueSet accounts = await connection.RequestAccountsByWindowTitle(windowTitle); if (accounts != null) { if (accounts.Count == 1) { return(accounts.First().Key); } return(await ShowFillScriptSelector(accounts, hWnd)); } return(null); }