Dec 27, 2015
Play together! Leaderboards with Windows Azure and Multiplayer with Wi-Fi DirectJianye LuProgram Manager
Priya DandawateProgram Manager3-051
Play games together!
Gamers have more funPlay with other people, and discover new people
Developers reach out to more gamersGrow user base through social networksBoost game usage with competition/cooperation among friends
New opportunitiesNew platform and new devices
Easily connect games with Proximity API
Build social backend with Windows Azure Mobile Services
Do more with our solutions
Agenda
Windows.Networking.Proximity
Easy to connect via Wi-Fi Direct or NFCNo AP requiredProximity discovers nearby PCs running your app in the
foregroundNo need to deal with IP addresses
Wi-Fi Direct provides a fast, high quality connection
Local P2P network; no AP required
Connection time: 3-10 secondsThroughput: 20 mbps – 30 mbpsLatency: 30-100msHigh through-put and low latency
Simple user experience
Windows takes care of the complexity of getting connected so you can focus on the gaming experience
PeerFinderHost Client
PeerFinder.Role = PeerRole.Client;
PeerFinder.ConnectionRequested += ConnectionRequested;
PeerFinder.TriggeredConnectionStateChanged += TriggeredConnectionStateChanged;
PeerFinder.Start();
PeerFinder.Role = PeerRole.Host; PeerFinder.TriggeredConnectionStateChanged += TriggeredConnectionStateChanged;
PeerFinder.Start();
Finding playersHost Client
PeerFinder.Role = PeerRole.Client;
PeerFinder.Start();
// Wait for Host to find and invite client.
private async void FindPeers(){ progressBar.Visibility = Visibility.Visible; try { var peerInfoCollection = await PeerFinder.FindAllPeersAsync(); if (peerInfoCollection.Count > 0) {
// Display nearby clients in a list ...
Connecting playersHost Client – incoming connection request
private async void ConnectionRequested(object sender, ConnectionRequestedEventArgs e){ List<string> existingInvitations = new List<string>(); existingInvitations.Add(e.PeerInformation.DisplayName);
...
ReceivedInvitationsHeader.Text = "STOMP invitations :-)";
progressBar.Visibility = Visibility.Collapsed;}
private async Task ConnectToPeers(PeerInformation peer){ progressBar.Visibility = Visibility.Visible; StreamSocket s = await PeerFinder.ConnectAsync(peer); ConnectedPeer temp = new ConnectedPeer(peer.DisplayName); connectedPeers[temp] = new SocketReaderWriter(s, this); ... startGameButton.Visibility = Visibility.Visible;}
Connecting players (continued)Host Client – connect
devices// Navigate client to a new page - WaitingForHost ...{ backButton.Visibility = Visibility.Collapsed;
WaitingForHostParameters parameters = (WaitingForHostParameters)navigationParameter; StreamSocket socket =
await PeerFinder.ConnectAsync(parameters.peer);
pageTitle.Text = "Connected! Waiting for Host..."; ...}
// Host connecting to client...
Tap and connectHost Client – connect
devicesprivate async void TriggeredConnectionStateChanged(object sender, TriggeredConnectionStateChangedEventArgs e){ if (e.State == TriggeredConnectState.PeerFound) { // Show indeterminate progress UI }
else if (e.State == TriggeredConnectState.Completed) { StreamSocket socket = e.Socket; WaitForHost(socket); }
else if (e.State == TriggeredConnectState.Failed) { // Inform challenger that connection failed }}
private async void TriggeredConnectionStateChanged(object sender, TriggeredConnectionStateChangedEventArgs e){ if (e.State == TriggeredConnectState.PeerFound) { // Show indeterminate progress UI }
else if (e.State==TriggeredConnectState.Completed) { socket = new SocketReaderWriter(e.Socket, this); } else if (e.State == TriggeredConnectState.Failed) { // Inform Game Leader that connection failed }}
Sending/Receiving data - timerHost Client
public async void ReadMessage(){ // Read incoming message from the socket uint bytesRead = await dataReader.LoadAsync(sizeof(uint)); uint messageLength = dataReader.ReadUInt32(); bytesRead = await dataReader.LoadAsync(messageLength); currentMessage = dataReader.ReadString(messageLength); ...}
private int ParseMessage(){ ... case Constants.OpCodeUpdateClientTime: if (gamePage != null) gamePage.UpdateClientTime(words[1]); break;
private void UpdateTime(TickOption option){ // Decrement the timer by 1 second
foreach (SocketReaderWriter tempsocket in connectedPeers.Values) { string message = string.Format( "{0} {1}",
Constants.OpCodeUpdateClientTime,
timeLeft.ToString(@"m\:ss"));
tempsocket.WriteMessage(message); }}
UX considerations
Keep user up-to-date on the state of the connection
Ex: indeterminate progress bars, text
Game terminologyTranslate Host/Client networking model into fun gaming
terminologyEx: Host – Game Leader, Client – Challenger/player
Network failure cases Host connection fails vs. Client connection fails
Don’t stop at Games…
Sharing photos and videos Drawing, painting, sketching…togetherLearning together – interactive virtual chalkboardsCollaborative DJ-ingEasy translators – multi-lingual chat room …
Proximity APIs provide a quick and easy way to get your app connected
Windows takes care of the complexity of getting connected so you can focus on the
gaming experience
Easily connect games with Proximity API
Build social backend with Windows Azure Mobile Services
Do more with our solutions
Agenda
Windows Azure Mobile Services
Use cloud storage for structured dataWith powerful server scripting and database management
Allow users to login with popular identity providersMicrosoft Account, Facebook, Twitter, and Google
Send push notificationsIntegrated with live tiles on Windows/Windows PhoneIntegrated with notifications on iOS/Android
Why Windows Azure Mobile Services?
Add a backend service to your game in minutesData storage, authentication, push notifications, and more
Cross-platform supportSDKs for Windows/Windows-Phone/iOS/Android/HTML5
Reliable, scalable and production readyEnjoy high availability, global reach across multiple data centers, and easily scale your backend up as required
Windows Azure Mobile Services provides preconfigured backend
First things first
Create and register your game with Windows Store
Sign up for Windows Azure Mobile Services
Create and connect your first mobile service
Adding leaderboard
Create tables on Azure server to record results and leaderboard
Update server-side scripts to insert new data and update leaderboard
Add client code to insert results and retrieve/display leaderboard
Adding authentication
Register an account provider
Connect your account provider with your app and your Azure mobile service
Add client code to bring up built-in log-in page
(Optionally) Restrict data access based on authentication
Adding push notifications
Register and connect Live Connect service
Acquire and store channels for push notifications
Update server side scripts to send out push notifications
Do more with Windows Azure Mobile Services
LeaderboardId and log-in Live tiles
AchievementsProfiles and data roamingToast notifications
→→ →
Do more with Windows Azure Mobile Services
LeaderboardId and log-in Live tiles
AchievementsProfiles and data roamingToast notifications
Match-makingId, preference, skillset, locations
→→ →
Do more with Windows Azure Mobile Services
LeaderboardId and log-in Live tiles
AchievementsProfiles and data roamingToast notifications
Match-makingId, preference, skillset, locations
Turn-based gamingId, game status, push notifications
→→ →
Command line tools
Scripts to automate the creation, verification, and deletion process of a mobile service
Integrated support in Visual Studio
Server Explorer to manage services, tables, and scripts
Wizard to set up push notifications
Windows Azure Mobile Services provides a preconfigured backend so you can focus on
your gaming contents and logic, not services.
http://aka.ms/mobileservices
Easily connect games with Proximity API
Build social backend with Windows Azure Mobile Services
Do more with our solutions
Agenda
Turnkey solutions for “Playing Together”
Find and play with people nearby
Games are personalId and log-in, profiles and data roaming, …
Games are connectedLeaderboard, achievements, live tiles, toasts, match-making, turn-based gaming, …
Let everyone play together!
With tools like Proximity APIs and Windows Azure Mobile Services, you can easily build connected games that allow gamers to play together in your games.
Resources
Proximity APIshttp://msdn.microsoft.com/en-us/library/windows/apps/windows.networking.proximity.peerfinder
Windows Azure Mobile Serviceshttp://aka.ms/mobileservices
Related Talks at //BUILD2-047, Building Games for Windows2-542, Mobile Services - Soup to Nuts3-511, Going Live and Beyond with Windows Azure Mobile Services3-116, Developing Windows Blue Apps with Mobile Services
Evaluate this session
Scan this QR code to evaluate this session and be automatically entered in a drawing to win a prize!
© 2013 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.