Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Social Gaming with Windows Phone and Azure

Social Gaming with Windows Phone and Azure

Presented at TechEd South Africa 2011

017286889e25c87cb44b20ceca2d1d79?s=128

Daron Yondem

October 19, 2011
Tweet

Transcript

  1. 17-20 OCTOBER 2011 DURBAN ICC

  2. Submit your session evaluation for a chance to win! Sponsored

    by MVA http://microsoftvirtualacademy.com
  3. Social Gaming with Windows Phone and Azure Daron Yondem Chief

    Architect | DEVELOAD Software Microsof Regional Director Silverlight MVP INETA MEA President
  4. Daron Yöndem is • Silverlight MVP • Microsoft Regional Director

    for MEA • INETA MEA President • Book Author about HTML5, ASP.NET AJAX, Silverlight • Architect at DEVELOAD Software • Blog at http://daron.yondem.com
  5. DEVELOAD is • Consulting – Software architecture and design –

    Custom software development of Windows, Web Windows Phone, Azure and Silverlight applications – Mentoring services to get you started and keep you going • Web site: www.deveload.com
  6. You Are... • Interested in building WP7 Games • Wondering

    what Cloud computing can offer to help your serve millions of gamers?
  7. Let’s start with... • What Cloud computing can offer? •

    What we have in hand with Windows Azure? • What kind of integration scenarios can happen between WP7 and Azure. • How can Azure help me fascilitade building Social Games reacing millions of people?
  8. Why Phone + Cloud? • The cloud levels the playing

    field • The cloud provides a larger pool of resources from which to pull • The cloud provides a way to reach across device platforms
  9. Why WP7 and Windows Azure? • PaaS: you build it,

    Windows Azure runs it • Automatic O/S patching • Scalable • Utility billing • Additional services (e.g. ACS, Traffic Manager, Caching, CDN, etc.) • Common development tools – Visual Studio – Languages – Emulators for development
  10. Identity

  11. Identity Options • Create your own (e.g. username + password,

    token) – Custom model – ASP.NET Membership Providers • Use a single existing identity system (e.g. Live Id, Facebook, etc.) • Outsource identity management (e.g. Access Control Service)
  12. To learn more … Authenticating Users in a Windows Phone

    7 App via Access Control Service, OData Services and Windows Azure http://bit.ly/wp7acs
  13. Storage

  14. Storage • SQL Azure – Relational database – Highly available

    – Managed for you as a service • Windows Azure Tables – Non-relational structured storage – Massive scale-out – OData • Windows Azure Blobs – Big files – REST
  15. SQL Azure: OData Service • Client sends data to web

    role • Web role stores data in SQL Azure Web Role (1) (2)
  16. Windows Azure Blobs: Public Blobs • Client sends data to

    web role • Web role stores data in blobs • Client fetches public blobs directly Web Role (1) (2) (3)
  17. Windows Azure Blobs: SAS • Client gets Shared Access Signature

    from web role • Client stores data in blobs • Client fetches public blobs directly Web Role
  18. Windows Azure Tables: Proxy Calls • Client sends data to

    web role • Web role stores data in blobs Web Role
  19. Do not store your secrets on the phone

  20. Services

  21. Web Role versus Worker Role • Web Role has IIS

    • Worker Role does not – DLL with Main() • Both implement the RoleEntryPoint
  22. Scaling Work in Windows Azure 1. Web role receives message

    2. Web role enqueues work 3. Worker role polls queue 4. Worker role sends notifications MPNS Worker Role Web Role (1) (2) (3) (4)
  23. Multitenancy • You can have more than one application running

    in your role instance
  24. Content Delivery Network CD N CD N CD N CD

    N CD N CD N
  25. Communications

  26. Communications • Two communication models – Phone-initiated – Cloud-initiated

  27. Phone-Initiated Communication Options • HTTP-based, request/response • Framework choices (WCF,

    OData, WebRequest, etc.) • Wire format choices (SOAP, JSON, POX, etc.)
  28. Cloud-Initiated Communication • Push Notifications – Single connection between phone

    and Microsoft Push Notification Service – Bandwidth- and battery-friendly – No guarantee of delivery • Three kinds of push notifications – Raw – send a message to an application – Toast – send a message to the user – Tile – update an image, title, or count
  29. Subscribing to Push Notifications • Phone opens a channel •

    Phone sends URL to cloud • Cloud pushes notifications via URL • Microsoft Push Notification service notifies phone MPNS Web Role
  30. Let’s go on with... • How can we build social

    games with Silverlight? • Performance Tips and Tricks
  31. First : Performance!

  32. Threading • UIThread – PerFrame Callbacks, Touch, Networking, User Code,

    Layout • RenderThread (Composition Thread) – Opacity, DoubleAnimations, Perspective Transforms, Rectangular Clips, RenderTransforms • Worker Threads
  33. • Application.Current.Host.Settings. • EnableFrameRateCounter = true; Fillrate

  34. Application.Current.Host.Settings.EnableRedrawRegions = true;

  35. Application.Current.Host.Settings.EnableCacheVisualization= true;

  36. Performance Strategy Minimize UI Thread Work Leverage Off-Thread Use the

    GPU Less is more!
  37. CacheMode = BitmapCache

  38. Visibility OR Opacity?

  39. JPEG or PNG? Faster Decoding Opacity

  40. XAML or Pictures?

  41. App Start-Up Delay Loading the Unneeded! Include applicationsplashscreen.jpg Use a

    splash screen
  42. DON’T! Non-rectangular clips Large textures ( > 2K pixels either

    way) Complex animations (e.g. ColorAnimation) Opacity mask
  43. Second: How To?

  44. Step 1 : Timer • CompositionTarget.Rendering – Frame Animations •

    DispatchTimer – It’s inside the UIThread • StoryBoard • System.Thread.Timer public partial class Page : UserControl { System.Threading.Timer Sayac; public Page() { InitializeComponent(); Sayac = new System.Threading.Timer(Tick, TOP, 500, 500); } public void Tick(object sender) { ((Ellipse)sender).Dispatcher.BeginInvoke(delegate() { ((Ellipse)sender).Height += 1; }); } }
  45. Step 2 : Graphics • 2D games easy to build

    inside Silverlight • What about 3D? – Kit3D - http://www.markdawson.org/kit3d/ – Balder - http://www.codeplex.com/Balder – XNA! • You can create a whole new 3D world!
  46. Step 3 : Audio • Windows Media Audio and MP3

    support. • XNA Libraries to play effects and wma files. • MediaElement can help you for background music. • You can even have live streams in your game!
  47. Final Step: Pyhsics • Farseer Pyhsics Engine – It’s for

    both Silverlight and XNA! – Includes helpers and behaviors easy to use inside Expression Blend!
  48. In Conclusion • Azure and Cloud – Helps us serve

    millions of gamers with web/worker roles, CDN, SQL Azure, Notification Services – Azure Toolkit for Windows Phone helps us there. • Performanca and tactics for WP7 game development – Composition Thread, DoubleAnimations, Performance Counter and so on. – Using Dispatcher and StoryBoards together.
  49. THANKS!!! daron@yondem.com http://daron.yondem.com

  50. Submit your session evaluation for a chance to win! Sponsored

    by MVA http://microsoftvirtualacademy.com