private async void OnWPFAppService(object sender, RoutedEventArgs e) { _appServiceConnection = new AppServiceConnection(); _appServiceConnection.AppServiceName = "com.cninnovation.wpfbridgesample"; _appServiceConnection.PackageFamilyName = "676efced-1da0-481b-8db0-97f991f1c4d0_2dq4k2rrbc0fy"; _appServiceConnection.RequestReceived += OnRequestReceived; AppServiceConnectionStatus status = await _appServiceConnection.OpenAsync(); if (status == AppServiceConnectionStatus.Success) { var valueSet = new ValueSet(); valueSet.Add("command", "test"); AppServiceResponse response = await _appServiceConnection.SendMessageAsync(valueSet); if (response.Status == AppServiceResponseStatus.Success) { string answer = string.Join(", ", response.Message.Values.Cast <string>().ToArray()); await new MessageDialog($"received {answer}").ShowAsync(); } else { await new MessageDialog("error send").ShowAsync(); } } else { await new MessageDialog(status.ToString()).ShowAsync(); } }
private async Task <string> SendMessageAsync(ValueSet message) { using (var connection = new AppServiceConnection()) { connection.AppServiceName = BookServiceName; connection.PackageFamilyName = BooksPackageFamilyName; AppServiceConnectionStatus status = await connection.OpenAsync(); if (status == AppServiceConnectionStatus.Success) { AppServiceResponse response = await connection.SendMessageAsync(message); if (response.Status == AppServiceResponseStatus.Success && response.Message.ContainsKey("result")) { string result = response.Message["result"].ToString(); return(result); } else { await ShowServiceErrorAsync(response.Status); } } else { await ShowConnectionErrorAsync(status); } return(string.Empty); } }
private static async Task <AppServiceConnection> BuildConnection() { try { var serviceConnection = new AppServiceConnection(); serviceConnection.AppServiceName = "FilesInteropService"; serviceConnection.PackageFamilyName = Package.Current.Id.FamilyName; serviceConnection.ServiceClosed += Connection_ServiceClosed; AppServiceConnectionStatus status = await serviceConnection.OpenAsync(); if (status != AppServiceConnectionStatus.Success) { // TODO: error handling serviceConnection?.Dispose(); return(null); } // Launch fulltrust process await FullTrustProcessLauncher.LaunchFullTrustProcessForCurrentAppAsync(); return(serviceConnection); } catch (Exception ex) { NLog.LogManager.GetCurrentClassLogger().Warn(ex, "Could not initialize AppServiceConnection!"); return(null); } }
public async Task SendMessageAsync(string message) { using (var connection = new AppServiceConnection()) { connection.AppServiceName = "com.cninnovation.bridgesample"; connection.PackageFamilyName = "6d982834-6814-4d82-b331-8644a7f54418_2dq4k2rrbc0fy"; AppServiceConnectionStatus status = await connection.OpenAsync(); if (status == AppServiceConnectionStatus.Success) { var valueSet = new ValueSet(); valueSet.Add("command", message); AppServiceResponse response = await connection.SendMessageAsync(valueSet); if (response.Status == AppServiceResponseStatus.Success) { string answer = string.Join(", ", response.Message.Values.Cast <string>().ToArray()); await _dialogService.ShowMessageAsync($"received {answer}"); } else { await _dialogService.ShowMessageAsync($"error sending message {response.Status.ToString()}"); } } else { await _dialogService.ShowMessageAsync(status.ToString()); } } }
//For a detailed introduction to AppServices on IoT, see the "AppServiceBlinky" sample //This app connects to the service and pushes messages every 30 seconds. public async void Run(IBackgroundTaskInstance taskInstance) { deferral = taskInstance.GetDeferral(); taskInstance.Canceled += TaskInstance_Canceled; connection = new AppServiceConnection(); connection.AppServiceName = "NotepadService"; connection.PackageFamilyName = "NotepadService-uwp_2yx4q2bk84nj4"; AppServiceConnectionStatus status = await connection.OpenAsync(); if (status != AppServiceConnectionStatus.Success) { return; } var message = new ValueSet(); //Send a message with an operation type of "postNote" and the desired "newNote" //Then, if successful, start a timer and send a new message periodically message.Add("operation", "postNote"); message.Add("newNote", "Hello, this is my first note. I will add another one every 30 seconds"); AppServiceResponse response = await connection.SendMessageAsync(message); if (response.Status == AppServiceResponseStatus.Success) { var result = response.Message["Result"].ToString(); timer = ThreadPoolTimer.CreatePeriodicTimer(this.Tick, TimeSpan.FromSeconds(30)); System.Diagnostics.Debug.WriteLine(result); } }
/// <summary> /// Open the connection to the App service /// </summary> /// <returns>The AppServiceConnectionStatus object giving the status of the connection</returns> public IAsyncOperation <AppServiceConnectionStatus> OpenConnectionAsync() { _log.Information("OpenConnectionAsync: called"); return(Task <AppServiceConnectionStatus> .Run(async() => { _log.Information("OpenConnectionAsync: Creating App Service Connection"); AppServiceConnection connection = new AppServiceConnection(); // Here, we use the app service name defined in the app service provider's Package.appxmanifest file in the <Extension> section. connection.AppServiceName = ServiceName; // Use Windows.ApplicationModel.Package.Current.Id.FamilyName within the app service provider to get this value. connection.PackageFamilyName = ServiceFamilyName; Status = await connection.OpenAsync(); bool bRet = Status == AppServiceConnectionStatus.Success; _log.Information($"OpenConnectionAsync: Connection Status = {Status.ToString()}"); if (bRet) { Connection = connection; } return Status; }).AsAsyncOperation <AppServiceConnectionStatus>()); }
private async System.Threading.Tasks.Task EnsureConnectionToSynonymsService() { if (this.synonymsServiceConnection == null) { synonymsServiceConnection = new AppServiceConnection(); // See the appx manifest of the AppServicesDemp app for this value synonymsServiceConnection.AppServiceName = "MicrosoftDX-SynonymsService"; // Use the Windows.ApplicationModel.Package.Current.Id.FamilyName API in the // provider app to get this value synonymsServiceConnection.PackageFamilyName = "82a987d5-4e4f-4cb4-bb4d-700ede1534ba_nsf9e2fmhb1sj"; AppServiceConnectionStatus connectionStatus = await synonymsServiceConnection.OpenAsync(); if (connectionStatus == AppServiceConnectionStatus.Success) { synonymsServiceConnection.ServiceClosed += (s, serviceClosedEventArgs) => { if (ServiceClosed != null) { ServiceClosed(this, serviceClosedEventArgs); } }; } else { //Drive the user to store to install the app that provides //the app service throw new NotImplementedException("Service not installed on this device"); } } }
private async Task ShowConnectionErrorAsync(AppServiceConnectionStatus status) { string error = null; switch (status) { case AppServiceConnectionStatus.AppNotInstalled: error = "The Book Cache service is not installed.Deploy the BooksCacheProvider."; break; case AppServiceConnectionStatus.AppUnavailable: error = "The Book Cache service is not available. Maybe an update is in progress, or the app location is not available"; break; case AppServiceConnectionStatus.AppServiceUnavailable: error = "The Book Cache service is not available"; break; case AppServiceConnectionStatus.Unknown: error = "Unknown error"; break; default: break; } await new MessageDialog(error).ShowAsync(); }
static async void ThreadProc() { //we create a connection with the App Service defined by the UWP app connection = new AppServiceConnection(); connection.AppServiceName = "BoardingPassService"; connection.PackageFamilyName = Windows.ApplicationModel.Package.Current.Id.FamilyName; connection.RequestReceived += Connection_RequestReceived; connection.ServiceClosed += Connection_ServiceClosed; //we open the connection AppServiceConnectionStatus status = await connection.OpenAsync(); if (status != AppServiceConnectionStatus.Success) { //if the connection fails, we terminate the Win32 process appServiceExit.Set(); } else { //if the connection is succesfull, we communicate to the UWP app that the channel has been established ValueSet initialStatus = new ValueSet(); initialStatus.Add("Status", "Ready"); await connection.SendMessageAsync(initialStatus); } }
private async System.Threading.Tasks.Task EnsureConnectionToService() { if (this.connection == null) { connection = new AppServiceConnection(); // See the appx manifest of the AppServicesDemp app for this value connection.AppServiceName = "microsoftDX-appservicesdemo"; // Use the Windows.ApplicationModel.Package.Current.Id.FamilyName API in the // provider app to get this value connection.PackageFamilyName = "82a987d5-4e4f-4cb4-bb4d-700ede1534ba_nsf9e2fmhb1sj"; AppServiceConnectionStatus connectionStatus = await connection.OpenAsync(); if (connectionStatus == AppServiceConnectionStatus.Success) { connection.ServiceClosed += OnServiceClosed; } else { //Drive the user to store to install the app that provides //the app service } } }
private async void InitializeAppServiceConnection() { try { connection = new AppServiceConnection { AppServiceName = "CommunicationService", PackageFamilyName = Package.Current.Id.FamilyName }; connection.RequestReceived += Connection_RequestReceived; connection.ServiceClosed += Connection_ServiceClosed; AppServiceConnectionStatus status = await connection.OpenAsync(); if (status != AppServiceConnectionStatus.Success) { await SendMessage("response", $"AppServiceConnectionStatus : {status.ToString()}"); Current.Shutdown(); } await SendMessage("response", "connet ok"); } catch (Exception ex) { await SendMessage("response", ex.ToString()); Current.Shutdown(); } }
private string GetStatusDetail(AppServiceConnectionStatus status) { var result = ""; switch (status) { case AppServiceConnectionStatus.Success: result = "connected"; break; case AppServiceConnectionStatus.AppNotInstalled: result = "AppServiceSample seems to be not installed"; break; case AppServiceConnectionStatus.AppUnavailable: result = "App is currently not available (could be running an update or the drive it was installed to is not available)"; break; case AppServiceConnectionStatus.AppServiceUnavailable: result = "App is installed, but the Service does not respond"; break; case AppServiceConnectionStatus.Unknown: result = "Unknown error with the AppService"; break; } return(result); }
public async Task <bool> StartAppServiceConnection(String listenerId) { var result = false; if (_connection != null) { _connection.Dispose(); _connection = null; } // Open a connection to the App Service _listenerId = listenerId; _connection = new AppServiceConnection(); _connection.AppServiceName = "com.microsoft.knowzy.appservice"; _connection.PackageFamilyName = Windows.ApplicationModel.Package.Current.Id.FamilyName; _connection.RequestReceived += Connection_RequestReceived; _connection.ServiceClosed += Connection_ServiceClosed; AppServiceConnectionStatus status = await _connection.OpenAsync(); if (status == AppServiceConnectionStatus.Success) { // register this App Service Connection as a listener ValueSet registerData = new ValueSet(); registerData.Add("Type", "Register"); registerData.Add("Id", listenerId); var response = await _connection.SendMessageAsync(registerData); if (response.Status == AppServiceResponseStatus.Success) { var message = response.Message; result = message.ContainsKey("Status") && message["Status"].ToString() == "OK"; } } return(result); }
private async void sendMessage() { AppServiceConnection appService = new AppServiceConnection(); appService.AppServiceName = "appservicesdemo"; appService.PackageFamilyName = "PackageFamilyName"; AppServiceConnectionStatus connectionStatus = await appService.OpenAsync(); if (connectionStatus == AppServiceConnectionStatus.Success) { var message = new ValueSet(); message.Add("Command", "SayHello"); AppServiceResponse response = await appService.SendMessageAsync(message); if (response.Status == AppServiceResponseStatus.Success) { string result = (string)response.Message["Result"]; await new MessageDialog(result).ShowAsync(); } } else { await new MessageDialog("Connection Failed ").ShowAsync(); } }
private async void hotkeys_HotkeyPressed(int ID) { if (hotkeyInProgress) { return; // prevent reentrancy } hotkeyInProgress = true; // bring the UWP to the foreground (optional) IEnumerable <AppListEntry> appListEntries = await Package.Current.GetAppListEntriesAsync(); await appListEntries.First().LaunchAsync(); // send the key ID to the UWP ValueSet hotkeyPressed = new ValueSet(); hotkeyPressed.Add("ID", ID); AppServiceConnection connection = new AppServiceConnection(); connection.PackageFamilyName = Package.Current.Id.FamilyName; connection.AppServiceName = "HotkeyConnection"; AppServiceConnectionStatus status = await connection.OpenAsync(); if (status != AppServiceConnectionStatus.Success) { Debug.WriteLine(status); Application.Exit(); } connection.ServiceClosed += Connection_ServiceClosed; AppServiceResponse response = await connection.SendMessageAsync(hotkeyPressed); }
private async Task <AppServiceConnection> GetAppConnectionAsync() { AppServiceConnection appConnection = _appConnection; if (appConnection == null) { appConnection = new AppServiceConnection(); appConnection.ServiceClosed += AppConnection_ServiceClosed; appConnection.AppServiceName = BackgroundOperation.AppServiceName; appConnection.PackageFamilyName = Windows.ApplicationModel.Package.Current.Id.FamilyName; AppServiceConnectionStatus status = await appConnection.OpenAsync(); if (status == AppServiceConnectionStatus.Success) { _appConnection = appConnection; _appConnection.RequestReceived += Connection_RequestReceived; } } return(appConnection); }
//// =========================================================================================================== //// Methods //// =========================================================================================================== public async Task <bool> InitializeAsync() { // open a connection to the UWP AppService AppServiceConnectionStatus result = await _connection.OpenAsync(); return(result == AppServiceConnectionStatus.Success); }
private static string GenerateMessage(AppServiceConnectionStatus status, AppServiceConnection connection) { switch (status) { case AppServiceConnectionStatus.Success: throw new ArgumentException("Success sollte keine Exception auslösen.", nameof(status)); case AppServiceConnectionStatus.AppNotInstalled: return("The app AppServicesProvider is not installed. Deploy AppServicesProvider to this device and try again."); case AppServiceConnectionStatus.AppUnavailable: return("The app AppServicesProvider is not available. This could be because it is currently being updated or was installed to a removable device that is no longer available."); case AppServiceConnectionStatus.AppServiceUnavailable: return(string.Format("The app AppServicesProvider is installed but it does not provide the app service {0}.", connection.AppServiceName)); case AppServiceConnectionStatus.Unknown: return("An unkown error occurred while we were trying to open an AppServiceConnection."); case AppServiceConnectionStatus.RemoteSystemUnavailable: return("The remote system is unavailable."); case AppServiceConnectionStatus.RemoteSystemNotSupportedByApp: return("The Remote System is not supported by the app."); case AppServiceConnectionStatus.NotAuthorized: return("You are not authorized."); default: return("Unknown failure"); } }
static async System.Threading.Tasks.Task <bool> ConnectToAppService() { bool bResult = false; LogMessage("Win32Proc: Connect To AppService"); connection = new AppServiceConnection(); connection.AppServiceName = AppServiceTaskConstant.APPSERVICENAME; connection.PackageFamilyName = AppServiceTaskConstant.APPSERVICEPACKAGEFAMILY; connection.RequestReceived += Connection_RequestReceived; connection.ServiceClosed += Connection_ServiceClosed; AppServiceConnectionStatus status = await connection.OpenAsync(); if (status == AppServiceConnectionStatus.Success) { bResult = true; // TODO: error handling LogMessage("Win32Proc: Connect To AppService Successful"); } else { LogMessage("Win32Proc: Failed to Connect To AppService - Status: " + status.ToString()); } return(bResult); }
public async void Run(IBackgroundTaskInstance taskInstance) { deferral = taskInstance.GetDeferral(); //Connect to the "BlinkyService" implemented in the "BlinkyService" solution connection = new AppServiceConnection(); connection.AppServiceName = "BlinkyService"; connection.PackageFamilyName = "BlinkyService-uwp_gpek5j0d8wyr0"; AppServiceConnectionStatus status = await connection.OpenAsync(); if (status != AppServiceConnectionStatus.Success) { deferral.Complete(); return; } //Send a message with the name "requestedPinValue" and the value "High" //These work like loosely typed input parameters to a method requestedPinValue = "High"; var message = new ValueSet(); message["requestedPinValue"] = requestedPinValue; AppServiceResponse response = await connection.SendMessageAsync(message); //If the message was successful, start a timer to send alternating requestedPinValues to blink the LED if (response.Status == AppServiceResponseStatus.Success) { timer = ThreadPoolTimer.CreatePeriodicTimer(this.Tick, TimeSpan.FromMilliseconds(500)); } }
public static AppConnectionStatus GetAppConnectionStatus(this AppServiceConnectionStatus status) { switch (status) { case AppServiceConnectionStatus.Success: return(AppConnectionStatus.Success); case AppServiceConnectionStatus.AppNotInstalled: return(AppConnectionStatus.AppNotInstalled); case AppServiceConnectionStatus.AppUnavailable: return(AppConnectionStatus.AppUnavailable); case AppServiceConnectionStatus.AppServiceUnavailable: return(AppConnectionStatus.AppServiceUnavailable); case AppServiceConnectionStatus.Unknown: return(AppConnectionStatus.Unknown); case AppServiceConnectionStatus.RemoteSystemUnavailable: return(AppConnectionStatus.RemoteSystemUnavailable); case AppServiceConnectionStatus.RemoteSystemNotSupportedByApp: return(AppConnectionStatus.RemoteSystemNotSupportedByApp); case AppServiceConnectionStatus.NotAuthorized: return(AppConnectionStatus.NotAuthorized); default: throw new ArgumentOutOfRangeException(nameof(status), status, null); } }
public override async Task <object> ExecuteAsync(ValueSet parameters) { if (_serviceName.IsNullorEmpty()) { throw new InvalidProgramException("Extension is not a service"); } try { // do app service call using (var connection = new AppServiceConnection()) { // service name was in properties connection.AppServiceName = _serviceName; // package Family Name is in the extension connection.PackageFamilyName = this.AppExtension.Package.Id.FamilyName; // open connection AppServiceConnectionStatus status = await connection.OpenAsync(); if (status != AppServiceConnectionStatus.Success) { throw new InvalidOperationException(status.ToString()); } else { // send request to service // get response AppServiceResponse response = await connection.SendMessageAsync(parameters); if (response.Status == AppServiceResponseStatus.Success) { ValueSet message = response.Message as ValueSet; if (message.ContainsKey("status") && (int)message["status"] == 1) { if (message.ContainsKey("search_result") && message["search_result"] is string s) { return(GetGenericMusicItem(s)); } if (message.ContainsKey("song_result") && message["song_result"] is string t) { return(GetOnlineSong(t)); } if (message.ContainsKey("album_result") && message["album_result"] is string r) { return(GetAlbum(r, message["songs"] as string, message["album_artists"] as string)); } } } } } return(null); } catch (Exception e) { throw e; } }
private async void OpenConnection_Click(object sender, Windows.UI.Xaml.RoutedEventArgs e) { //Is a connection already open? if (connection != null) { rootPage.NotifyUser("A connection already exists", NotifyType.ErrorMessage); return; } //Set up a new app service connection connection = new AppServiceConnection(); connection.AppServiceName = "com.microsoft.randomnumbergenerator"; connection.PackageFamilyName = "Microsoft.SDKSamples.AppServicesProvider.CS_8wekyb3d8bbwe"; connection.ServiceClosed += Connection_ServiceClosed; AppServiceConnectionStatus status = await connection.OpenAsync(); //"connection" may have been nulled out while we were awaiting. if (connection == null) { rootPage.NotifyUser("Connection was closed", NotifyType.ErrorMessage); return; } //If the new connection opened successfully we're done here if (status == AppServiceConnectionStatus.Success) { rootPage.NotifyUser("Connection is open", NotifyType.StatusMessage); } else { //Something went wrong. Lets figure out what it was and show the //user a meaningful message switch (status) { case AppServiceConnectionStatus.AppNotInstalled: rootPage.NotifyUser("The app AppServicesProvider is not installed. Deploy AppServicesProvider to this device and try again.", NotifyType.ErrorMessage); break; case AppServiceConnectionStatus.AppUnavailable: rootPage.NotifyUser("The app AppServicesProvider is not available. This could be because it is currently being updated or was installed to a removable device that is no longer available.", NotifyType.ErrorMessage); break; case AppServiceConnectionStatus.AppServiceUnavailable: rootPage.NotifyUser(string.Format("The app AppServicesProvider is installed but it does not provide the app service {0}.", connection.AppServiceName), NotifyType.ErrorMessage); break; default: case AppServiceConnectionStatus.Unknown: rootPage.NotifyUser("An unknown error occurred while we were trying to open an AppServiceConnection.", NotifyType.ErrorMessage); break; } //Clean up before we go connection.Dispose(); connection = null; } }
public ASConnectionConnectResult( AppServiceConnectionStatus connectionStatus, AppServiceHandshakeStatus handshakeStatus, ASConnection connection) { ConnectionStatus = connectionStatus; HandshakeStatus = handshakeStatus; Connection = connection; }
static async void ThreadProc() { connection = new AppServiceConnection(); connection.AppServiceName = "com.ilink-systems.wpfappservice"; connection.PackageFamilyName = Windows.ApplicationModel.Package.Current.Id.FamilyName; connection.RequestReceived += Connection_RequestReceived; AppServiceConnectionStatus status = await connection.OpenAsync(); }
public async Task <string> GetResponse(string question) { var result = ""; using (SampleAppServiceConnection = new AppServiceConnection()) { //declaring the service and the package family name SampleAppServiceConnection.AppServiceName = "com.msiccdev.sampleappservice"; //this one can be found in the Package.appxmanifest file SampleAppServiceConnection.PackageFamilyName = "acc75b1a-8b90-4f18-a2c4-08b0d700f1c6_62er76fr5b6k0"; //trying to connect to he AppService AppServiceConnectionStatus status = await SampleAppServiceConnection.OpenAsync(); //no success with the AppServiceConnection if (status != AppServiceConnectionStatus.Success) { return(GetStatusDetail(status)); } //if successful else { //sending the input parameters var input = new ValueSet() { { "question", question } }; AppServiceResponse response = await SampleAppServiceConnection.SendMessageAsync(input); //handling the response switch (response.Status) { case AppServiceResponseStatus.Success: result = (string)response.Message["response"]; break; case AppServiceResponseStatus.Failure: result = "app service called failed, most likely due to wrong parameters sent to it"; break; case AppServiceResponseStatus.ResourceLimitsExceeded: result = "app service exceeded the resources allocated to it and had to be terminated"; break; case AppServiceResponseStatus.Unknown: result = "unknown error while sending the request"; break; } } } return(result); }
/// <summary> /// Try connecting to Quarrel /// </summary> /// <param name="connectIfClosed">Connect to Quarrel when it is opened, if it is currently closed</param> /// <returns></returns> public async Task TryConnectAsync(bool connectIfClosed) { connection.RequestReceived += Connection_RequestReceived; connection.ServiceClosed += Connection_ServiceClosed; connection.AppServiceName = "Quarrel.Presence"; connection.PackageFamilyName = "38062AvishaiDernis.DiscordUWP_q72k3wbnqqnj6"; Status = await connection.OpenAsync(); Console.WriteLine("AppService connection status=" + Status); }
private async void btnConnect_Click(object sender, RoutedEventArgs e) { //if (this.CashierServiceConnection == null) //{ #region Appunavailable testing //for(int i=0;i<8; i++) //{ // CashierServiceConnection = new AppServiceConnection(); // CashierServiceConnection.AppServiceName = "SunCashierService"; // CashierServiceConnection.PackageFamilyName = "62762cd1-1887-405e-93cc-30d1754f1737_75cr2b68sm664"; // CashierServiceConnection.ServiceClosed += Conn_ServiceClosed; // AppServiceConnectionStatus connectionStatus2 = await CashierServiceConnection.OpenAsync(); // System.Diagnostics.Debug.WriteLine(connectionStatus2.ToString()); //} #endregion CashierServiceConnection = new AppServiceConnection(); CashierServiceConnection.AppServiceName = "SunCashierSecondService"; CashierServiceConnection.PackageFamilyName = "62762cd1-1887-405e-93cc-30d1754f1737_75cr2b68sm664"; CashierServiceConnection.ServiceClosed += Conn_ServiceClosed; AppServiceConnectionStatus connectionStatus = await CashierServiceConnection.OpenAsync(); if (connectionStatus == AppServiceConnectionStatus.Success) { await new MessageDialog("Connection is open.").ShowAsync(); return; } switch (connectionStatus) { case AppServiceConnectionStatus.AppNotInstalled: await new MessageDialog("The app AppServicesProvider is not installed. Deploy AppServicesProvider to this device and try again.").ShowAsync(); break; case AppServiceConnectionStatus.AppUnavailable: await new MessageDialog("The app AppServicesProvider is not available. This could be because it is currently being updated or was installed to a removable device that is no longer available.").ShowAsync(); break; case AppServiceConnectionStatus.AppServiceUnavailable: await new MessageDialog(string.Format("The app AppServicesProvider is installed but it does not provide the app service {0}.", CashierServiceConnection.AppServiceName)).ShowAsync(); break; case AppServiceConnectionStatus.Unknown: await new MessageDialog("An unkown error occurred while we were trying to open an AppServiceConnection.").ShowAsync(); break; } //} //else //{ // await new MessageDialog("A connection is already open").ShowAsync(); //} }
public async void Init() { appServiceConnection = new AppServiceConnection { PackageFamilyName = Package.Current.Id.FamilyName, AppServiceName = "SystrayExtensionService" }; appServiceConnection.RequestReceived += Connection_RequestReceived; appServiceConnection.ServiceClosed += Connection_ServiceClosed; connectionStatus = await appServiceConnection.OpenAsync(); }
public virtual async Task OpenConnectionAsync() { if (!ConnectionAlive) { AppServiceConnectionStatus status = await Connection.OpenAsync(); if (status == AppServiceConnectionStatus.Success) { ConnectionAlive = true; } } }