1 / 39

Real time communication: keep your Metro style app connected whether it is running or suspended

APP-410T. Real time communication: keep your Metro style app connected whether it is running or suspended. Raghu Gatta Principal Development Lead Microsoft Corporation. Kamal Srinivasan Program Manager Microsoft Corporation. Agenda. Real Time Communication (RTC) app requirements

patsy
Download Presentation

Real time communication: keep your Metro style app connected whether it is running or suspended

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. APP-410T Real time communication: keep your Metro style app connected whether it is running or suspended Raghu Gatta Principal Development Lead Microsoft Corporation Kamal Srinivasan Program Manager Microsoft Corporation

  2. Agenda • Real Time Communication (RTC) app requirements • User in control of the RTC apps • Building your RTC app in Windows 8 You’ll leave knowing how to • Build communication apps that work 24x7

  3. Customer promise in Windows 8 Longer battery life Always reachable apps

  4. Review app process lifetime Running App Suspended App Terminated App Suspending Low Memory Resuming

  5. What about RTC apps? VoIP IM Mail RTC apps that need to be always reachable

  6. Windows enables you to develop apps that are always reachable!

  7. The app lifecycle …with RTC apps Background Task Executes Background Task Executes Background Task Executes Running App Suspended App Terminated App Suspending Low Memory Resuming

  8. demo Chat app (PingMe) Running an app in the background

  9. RTC trigger APIs for your apps App OS VoIP IM Mail Network Trigger System Trigger Time Trigger Background Task Infrastructure

  10. Building an always reachable IM app

  11. Building an IM app on Windows 8 System Trigger Network Trigger VoIP IM Mail Network Trigger System Trigger Time Trigger Receive an IM when app is in the background Background Task Infrastructure Receive an IM after user logs in

  12. Execution Pattern App OS App registers for trigger OS waits Trigger fires Background task executes

  13. Network Trigger Register for IM network trigger Open your socket usingWindows.Networking.Sockets; StreamSocket sock = newStreamSocket(); // Connect the streamsocket … Add Control Channel metadata // Create a Notification Channel with Push capability NotificationChannelnc = newNotificationChannel( "channelOne", “MyApp.Background.KeepAliveTask", “MyApp.Background.PushNotifyTask", ServerKATimeInMins); Register your socket // Associate the socket with the notification channel channelStatus = nc.UsingTransport(sock);

  14. Network Trigger App execution upon receiving IM usingWindows.ApplicationModel.Background; publicsealedclassPushNotifyTask : IBackgroundTask{ publicvoidRun(IBackgroundTaskInstancetaskInstance) { // Handle Incoming message // Throwing a toast code } } } }

  15. Keep Alive maintains your control channel Network Keep alive Interval Server Keep alive Interval

  16. Network Trigger App execution on Keep Alive usingWindows.ApplicationModel.Background; publicsealedclassKeepAliveTask: IBackgroundTask{ publicvoidRun(IBackgroundTaskInstancetaskInstance) { // Send Keepalive message to remote server } }} } }

  17. System Trigger Register on User Login Create user login trigger usingWindows.ApplicationModel.Background; // Specify the trigger IBackgroundTrigger trigger = newSystemTrigger(SystemTriggerType.SessionStart, false); Associate trigger with app code // Associate app code with the trigger BackgroundTaskBuildertaskBuilder = newBackgroundTaskBuilder(); taskBuilder.TaskEntryPoint = “MyApp.Background.RegisterForUserLogin"; taskBuilder.SetTrigger(trigger); taskBuilder.Name = “OnUserPresent"; Register trigger // Register the task for background execution IBackgroundTaskRegistrationtaskRegistration = taskBuilder.Register();

  18. System Trigger App execution on User Login usingWindows.ApplicationModel.Background; publicsealedclassRegisterForUserLogin: IBackgroundTask{ publicvoidRun(IBackgroundTaskInstancetaskInstance) { // Your app code to create notification channel } }

  19. demo Chat app (PingMe) Receive an IM when in “Connected Standby”

  20. Always connected Mobile broadband (e.g. 3G, 4G, LTE, etc.) Network Connectivity

  21. How does this work in connected standby?

  22. Nothing special,one model to stay connected.

  23. Building a POP mail client with periodic updates

  24. Building a POP mail app on Windows 8 VoIP IM Mail Time Trigger Network Trigger System Trigger Time Trigger Periodic Mail Sync Background Task Infrastructure

  25. Time Trigger Register for Periodic Mail Sync Create time trigger usingWindows.ApplicationModel.Background; // Specify the trigger TimeTriggertrigger = newTimeTrigger(UpdateInterval, Periodic); Associate trigger with app code // Associate app code with the trigger BackgroundTaskBuildertaskBuilder = newBackgroundTaskBuilder(); taskBuilder.TaskEntryPoint = “MyApp.Background.UpdateEmailTask"; taskBuilder.SetTrigger(trigger); taskBuilder.Name = “TimerExpiry"; Register trigger // Register the task for background execution IBackgroundTaskRegistrationtaskRegistration = taskBuilder.Register();

  26. Time Trigger App execution upon timer expiry usingWindows.ApplicationModel.Background; publicsealedclassUpdateEmailTask: IBackgroundTask{ publicvoidRun(IBackgroundTaskInstancetaskInstance) { // Your app code to update email } } }

  27. Review

  28. Key points Longer Battery Life Always Reachable Apps

  29. Write your RTC app code using background tasks. Key points Your app will be always reachable in connected standby.

  30. Related sessions • [APP-409T] Fundamentals of Metro style apps: how and when your app will run • [HW-456T] Understanding Connected Standby • [HW-566T] Networking for connected standby • [PLAT-785T] Creating connected apps that work on today's networks • [APP-396T] Using tiles and notifications

  31. Further reading and documentation • Introduction to Background Tasks • http://go.microsoft.com/fwlink/?LinkID=227329&clcid=0x409 • Contact info – AskRtcDev@microsoft.com (optional)

  32. thank you Feedback and questions http://forums.dev.windows.com Session feedbackhttp://bldw.in/SessionFeedback

  33. © 2011 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

  34. Backup

  35. Lock Screen API sample voidAddToLockScreen() { IAsyncOperation<LockScreenState> operation = LockScreen.AddToLockScreenAsync(); operation.Completed = OnAddToLockScreenOperationCompleted; operation.Start(); } voidOnAddToLockScreenOperationCompleted(IAsyncOperation<LockScreenState> operation) { if (operation.Status == AsyncStatus.Completed)     { LockScreenState result = operation.GetResults(); switch (result)         { caseLockScreenState.NotOnLockScreen: break; caseLockScreenState.OnLockScreen: break; caseLockScreenState.DefaultNotOnLockScreen: break;         }     } else if (operation.Status == AsyncStatus.Error){ // Report error     } }

  36. System Event Registering for Network Change usingWindows.ApplicationModel.Background; // Specify the trigger IBackgroundTriggertrigger = newSystemTrigger(SystemTriggerType.NetworkStateChange, false); // Associate app code with the trigger BackgroundTaskBuildertaskBuilder= newBackgroundTaskBuilder(); taskBuilder.TaskEntryPoint= “MyAppBackground.NetworkStateChangeTask"; taskBuilder.SetTrigger(trigger); taskBuilder.Name= “OnNetworkStateChange"; // Register the task for background execution IBackgroundTaskRegistrationtaskRegistration= taskBuilder.Register();

  37. System Event App execution upon network change using Windows.ApplicationModel.Background; publicsealedclassNetworkStateChangeTask: IBackgroundTask{ publicvoidRun(IBackgroundTaskInstancetaskInstance) { // Re-register Notification Channel } }

More Related