public async Task <RomeAppServiceConnectionStatus> Connect(object _remoteSystem, bool keepAlive, Uri wakeUri) { var rs = _remoteSystem as RemoteSystem; if (rs == null) { throw new InvalidCastException(); } remoteSystem = rs; if ((wakeUri != null) && (!rs.IsAvailableByProximity) && (rs.Kind.Value == RemoteSystemKinds.Phone.Value)) { //Wake device first var wakeResult = await LaunchUri(wakeUri, rs); if (wakeResult == RomeRemoteLaunchUriStatus.Success) { RemoteSystem rsNew = await RediscoverRemoteSystem(rs); System.Diagnostics.Debug.WriteLine(rsNew.IsAvailableByProximity); if (rsNew == null) { return(RomeAppServiceConnectionStatus.RemoteSystemUnavailable); } else { rs = rsNew; } } } try { if (sendSemaphore.CurrentCount == 0) { sendSemaphore.Release(); } } catch { } connectionRequest = new RemoteSystemConnectionRequest(rs); appService = new AppServiceClientConnection(appServiceName, appIdentifier, connectionRequest); var result = await appService.OpenRemoteAsync(); var finalResult = result.ConvertToRomeAppServiceConnectionStatus(); if (finalResult == RomeAppServiceConnectionStatus.AppNotInstalled) { await LaunchStoreForApp(_remoteSystem); } return(finalResult); }
private async void ConnectAppService(string appService, string appIdentifier, RemoteSystemConnectionRequest connectionRequest) { this.appServiceClientConnection = new AppServiceClientConnection(appService, appIdentifier, connectionRequest); this.id = connectionRequest.RemoteSystem.Id; try { var status = await this.appServiceClientConnection.OpenRemoteAsync(); Console.WriteLine("App Service connection returned with status " + status.ToString()); } catch (ConnectedDevicesException e) { Console.WriteLine("Failed during attempt to create AppServices connection"); e.PrintStackTrace(); } }