Descargar la presentación
La descarga está en progreso. Por favor, espere
Publicada porAlfredo Benítez Palma Modificado hace 8 años
1
#helloWindows10 Hel10 Windows 10!
2
#helloWindows10 Alex Casquete Carlos Carrillo Construyendo una suite empresarial con App Services
4
#helloWindows10 Desarrollador en Plain Concepts acasquete@plainconcepts.com @acasquete Desarrollador en Plain Concepts ccarrillo@plainconcepts.com @3lcarry
5
#helloWindows10 Comunicación App to App Activar por URI una app específica Enviar archivos Soporte para consultar Uri Storage compartido App Services Agenda
6
#helloWindows10 Anteriormente en Windows 8.1
7
App to App en Windows 8.1 Contrato compartir DataTransferManager.ShowShare UI(); El usuario elige la aplicación destino
8
Launcher.LaunchUriAsync(new Uri("sampleapp:?ID=aea6")); Launcher.LaunchFileAsync(file); App to App en Windows 8.1 Protocol URI/Protocolo Usuario/OS elige app
9
App to App en Windows 10 UWP
10
App to App UWP ofrece muchas APIs que permiten interactuar con la plataforma Windows.ApplicationModel.Contacts Windows.ApplicationModel.Email Windows.System.Launcher.LaunchUriAsync para lanzar configuración, mapas, tienda, etc…
11
App to App Además las aplicaciones pueden interactuar Asociación Uri mediante LaunchUriAsync Asociación fichero mediante LaunchFileAsync Lanzar para obtener resultados mediante LaunchUriForResultsAsync App Services
12
Mejoras App to App en Windows 10 Enviar token de archivo, enviar datos Lanzar una app específica App Services Lanzar para obtener resultados
13
DEMO App to App en Windows 10
14
URI Activation++ Invoke a specific app var options = new LauncherOptions(); options.TargetApplicationPackageFamilyName = "24919.InstapaperIt"; var launchUri = new Uri("instapaper:?AddUrl=http%3A%2F%2Fbing.com"); await Launcher.LaunchUriAsync(launchUri, options);
15
URI Activation++ Send Files var options = new LauncherOptions(); options.TargetApplicationPackageFamilyName = "24919.InstapaperIt"; var token = SharedStorageAccessManager.AddFile (gpxFile); ValueSet inputData = new ValueSet(); inputData.Add("Token", token); var launchUri = new Uri("instapaper:?AddUrl=http%3A%2F%2Fbing.com"); await Launcher.LaunchUriAsync(launchUri, options, inputData);
16
Query URI Support Discover if app already installed to handle a Uri var queryUri = new Uri("instapaper:"); await Launcher.QueryUriSupportAsync(queryUri, LaunchUriType.LaunchUri); ? var queryUri = new Uri("instapaper:"); string packageFamilyName = "24919.InstapaperIt"; await Launcher.QueryUriSupportAsync(queryUri, LaunchUriType.LaunchUriForResults, packageFamilyName);
17
Launch for Results Launching the app var options = new LauncherOptions(); options.TargetApplicationPackageFamilyName = "24919.Instap"; var launchUri = new Uri("instapaper:?AddUrl=http%3A%2F%2Fbing.com"); await Launcher.LaunchUriForResultsAsync(launchUri, options, data); var resultData = new ValueSet(); resultData.Add("Result", value); operation.ProtocolForResultsOperation.ReportCompleted(resultData);A App1App2
18
URI Activation for Device Settings CategorySettings pageMobile and/or DesktopUri System Display (on desktop) Screen (on mobile) Bothms-settings://screenrotation NotificationsBothms-settings://notifications Storage SenseBothms-settings://storagesense Battery SaverBothms-settings://batterysaver MapsBothms-settings://maps DevicesBluetoothBothms-settings://bluetooth Network and Wi-fi Wi-FiBothms-settings://network/wifi Airplane modeBothms-settings://network/airplanemode CellularBothms-settings://network/cellular Data SenseBothms-settings://datasense NFCMobile onlyms-settings://proximity ProxyDesktop onlyms-settings://network/proxy More… [See documentation for complete list]
19
#helloWindows10 Apps del mismo publicador pueden compartir carpetas
20
Carpeta de publicador compartida
21
Interacción con carpetas compartidas Acceso a carpeta compartida Windows.Storage.ApplicationData.Current.GetPublisherCacheFolder("Folder"); Limpiar carpeta compartida Windows.Storage.ApplicationData.Current.ClearPublisherCacheFolderAsync("Folder");
22
DEMO
23
Drag and Drop
24
…experiencia en Windows
25
…pero sin soporte en aplicaciones WinRT
26
Hasta ahora! … AppExplorador de archivos
27
Simple in XAML: New in UIElement Drag source: Drag target: <Button x:Name="Copy" AllowDrop="True" DragOver="Copy_DragOver" DragLeave="Clear_DragLeave" Drop="Copy_Drop" Style="{StaticResource DropTargetButton}" >
28
Sharing source fills DataPackage async private void DragImage_DragStarting(UIElement sender, DragStartingEventArgs args) { // get the file StorageFolder installFolder = Windows.ApplicationModel.Package.Current.InstalledLocation; StorageFolder subFolder = await installFolder.GetFolderAsync("Assets"); var file = await subFolder.GetFileAsync("MSLogoImage.png"); // turn it into a stream and set it as a bitmap in the datapackage var stream = await file.OpenAsync(Windows.Storage.FileAccessMode.Read); args.Data.SetBitmap(RandomAccessStreamReference.CreateFromStream(stream)); // also set it as a file in the datapackage var files = new List (); files.Add(file); args.Data.SetStorageItems(files); args.Data.RequestedOperation = SetRequestedOperation(); }
29
Share Target unpacks DataPackage private async void Copy_Drop(object sender, DragEventArgs e) { TitleTextBlock.Text = e.DataView.Properties.Title; DescriptionTextBlock.Text = e.DataView.Properties.Description; // Get the text and the first file from the data package SharedTextTextBlock.Text = await e.DataView.GetTextAsync(); var photoFile = (StorageFile)(await e.DataView.GetStorageItemsAsync())[0]; // Show the image that has been dropped onto us var imageSource = new BitmapImage(); imageSource.SetSource(await photoFile.OpenReadAsync()); sharedPhotoImage.Source = imageSource; }
30
DEMO
31
Con App Services, las aplicaciones pueden proveer servicios a otras aplicaciones.
32
“Servicios Web” en el dispositivo Cliente A Cliente B Background Task Aplicación con App Service
33
Escenario: Bar Code Scanning Bar Code decoding App Service Image bytes in ValueSet or FileToken Decoded data
34
Escenario: Suite Empresarial de Aplicaciones App Service Inventario en cache Cliente A Cliente B Interación con Servicio Web App Service Proximity Reading Services
35
Comunicación Bidireccional Cliente y “Servidor” pueden mantener abierta una comunicación bidireccional. El cliente también puede subscribirse al evento “RequestReceived” Ambos pueden Enviar y Recibir mensajes.
36
DEMO App Services
37
AppServiceConnection connection = new AppServiceConnection(); connection.AppServiceName = "microsoftDX-appservicesdemo"; connection.PackageFamilyName = "24919ArunjeetSingh.InstapaperIt"; AppServiceConnectionStatus connectionStatus = await connection.OpenAsync(); if (connectionStatus == AppServiceConnectionStatus.Success) { //Send data to the service var message = new ValueSet(); message.Add("Command", "CalcSum"); message.Add("Value1", Int32.Parse(Value1.Text)); message.Add("Value2", Int32.Parse(Value2.Text)); //Send message and wait for response AppServiceResponse response = await connection.SendMessageAsync(message); if (response.Status == AppServiceResponseStatus.Success) { int sum = (int)response.Message["Result"]; new MessageDialog("Result=" + sum).ShowAsync(); } } else { //Drive the user to store to install the app that provides the app service } App Services – Client
38
namespace AppServicesDemoTask { public sealed class AppServiceTask : IBackgroundTask { private static BackgroundTaskDeferral _serviceDeferral; public void Run(IBackgroundTaskInstance taskInstance) { // Associate a cancellation handler with the background task. taskInstance.Canceled += TaskInstance_Canceled; // Get the deferral object from the task instance _serviceDeferral = taskInstance.GetDeferral(); var appService = taskInstance.TriggerDetails as AppServiceTriggerDetails; if (appService.Name == "microsoftDX-appservicesdemo") { //Maybe ValidateCaller(appService.CallerPackageFamilyName) ?? appService.AppServiceConnection.RequestReceived += RequestReceived; } }... App Services – Service (1/2)
39
private async void RequestReceived(AppServiceConnection sender, AppServiceRequestReceivedEventArgs args) { var message = args.Request.Message; // This service uses a Command keyed entry for the client to invoke services from the App Service string command = message["Command"] as string; switch (command) { case "DoIt": { var messageDeferral = args.GetDeferral(); int value1 = (int)message["Value1"];... Do some processing //Set a result to return to the caller var returnMessage = new ValueSet(); returnMessage.Add("Result", result); var responseStatus = await args.Request.SendResponseAsync(returnMessage); messageDeferral.Complete(); break; } case "Quit": { //Service was asked to quit. Complete service deferral so platform can terminate _serviceDeferral.Complete(); break; } } } App Services – Service (2/2)
40
Declaring App Service
41
Debugging Tips Debugging your App Service
42
Getting the Service PackageFamilyName Later on, ‘Store – Associate App with the Store’ sets the correct PackageFamilyName In Tech Preview, Store not open yet for UAP Call Package.Current.Id.FamilyName to return PFN to use in debugging
43
Debugging App Services 1. Set breakpoints in app service code 2. Check ‘Do not launch but debug my code when it starts’ in project properties 3. Launch app service foreground app in debugger – nothing happens! 4. Run client app to connect to app service 5. Debugger attaches and breaks on your breakpoint
44
DEMO App Services
45
Los App services proporcionan otra forma de comunicar las aplicaciones.
46
Más consideraciones sobre App Services…
47
Ciclo de vida Se activan bajo demanda Los clientes pueden finalizar el servicio liberando la conexión o enviando un mensaje para que se finalize Al suspender la app los app services invocados se finalizan. Insuficientes recursos pueden causar error al ejecutar o finalizar el servicio AppServiceConnectionStatus.ResourcesNotAvailable AppServiceResponseStatus.ResourceLimitsExceeded
48
¿Qué protocolo utiliza? App Services están diseñados para ser flexibles y ligeros y se modelan como servicios web REST. API de mensajes Request-Response Datos empaquetados como ValueSets Fácil de utilizar con distintos tipos de mensaje Cuando publicamos un App Service, definimos un endpoint Un endpoint de App Service proporciona a la app una forma de enviar datos al servicio y esperar por resultados.
49
Crea un SDK Cliente Crea una serie de métodos más funcionales y más significativos que faciliten todos los detalles de implementación de la comunicación. Publica un SDK cliente para tu Servicio Distribuye el SDK como paquete NuGet o similar
50
Securizar App Services Construir nuestros propios mecanismos de validación encima de app services. La forma más simple es mediante una whitelist basada en el PackageFamilyName El PackageFamilyName de la app se llama con cada petición Posibilidad de construir una validación más compleja utilizando ValueSets una vez la connexion se ha establecido Whitelist puede estar seguida por un intercambio de certificado X.509.
51
Versionado Sigue el modelo de versionado de Web REST API Si necesitas hacer un breaking change en un App Service endpoint, debes exponer un nuevo endpoint y proporcionar compatibilidad con el antiguo.
52
#helloWindows10 App to app Lanzar una app específica Lanzar una app para obtener resultados Enviar token de archivo App Services
53
#helloWindows10 Q&A http://aka.ms/W10Ev06
54
#helloWindows10 No olvides realizar la encuesta ¡Gracias! Alex Casquete acasquete@plainconcepts.com @acasquete http://aka.ms/W10Ev06 Carlos Carrillo ccarrillo@plainconcepts.com @3lcarry
Presentaciones similares
© 2024 SlidePlayer.es Inc.
All rights reserved.