+ All Categories
Home > Documents > Networking in Windows Phone 8

Networking in Windows Phone 8

Date post: 05-Jan-2016
Category:
Upload: awena
View: 56 times
Download: 1 times
Share this document with a friend
Description:
Networking in Windows Phone 8. Peter Torr Program Manager, Windows Phone Developer Platform 2-222. Agenda. HTTP Sockets Proximity Tips and Tricks. Choosing the Right API. .NET HttpClient. Windows 8.x. Windows Phone 8 Platform. WinRT Sockets. WCF. Desktop . NET. .NET Sockets. - PowerPoint PPT Presentation
34
Transcript
Page 1: Networking in Windows Phone 8
Page 2: Networking in Windows Phone 8

Networking in Windows Phone 8

Peter TorrProgram Manager, Windows Phone Developer Platform2-222

Page 3: Networking in Windows Phone 8

Agenda

HTTP

Sockets

Proximity

Tips and Tricks

Page 4: Networking in Windows Phone 8

Choosing the Right API

Page 5: Networking in Windows Phone 8

Windows 8.x

Legacy C++

Desktop .NET

Windows Phone 7.xHttpWebRequest

WebClient

.NET Sockets

.NET HttpClient

WinRT Sockets

WCF

Win

dow

s Ph

one 8

Pla

tform

WinSock

IXmlHttpRequest2

Page 6: Networking in Windows Phone 8

WinRT Sockets

IXmlHttpRequest2

WinRT Sockets

.NET HttpClient

.NET

C++

Win

dow

s Ph

one 8

Pla

tform

Page 7: Networking in Windows Phone 8

Setting up your Development Machine

Page 8: Networking in Windows Phone 8

Step 1: Get your IPv4 address

From elevated command prompt

C:\>ipconfig

Windows IP Configuration

Ethernet adapter vEthernet (don't pick the Emulator): [...] IPv4 Address. . . . . . . . . . . : 192.168.0.123

Page 9: Networking in Windows Phone 8

Step 2: Add binding for IISExpress

Update the IISExpress config file%userprofile%\Documents\IISExpress\config\applicationhost.config

<site name="TestApp" id="1"> <...> <binding protocol="http" bindingInformation="*:45678:localhost" /> <binding protocol="http" bindingInformation="*:45678:192.168.0.123" />

Page 10: Networking in Windows Phone 8

Step 3: Add reservation for http.sys

From elevated command-prompt:

C:\>netsh http add urlacl url=http://192.168.0.123:45678/ user=everyone

Page 11: Networking in Windows Phone 8

Step 4: Enable traffic through firewall

From elevated command-prompt:

C:\>netsh advfirewall firewall add rule dir=in action=allow protocol=tcp localport=45678 remoteip=localsubnet profile=private,domain name=TestApp

Page 12: Networking in Windows Phone 8

HTTP APIs

Page 13: Networking in Windows Phone 8

.NET HttpClient

Simple, modern API based on async pattern

Built in to .NET 4.5 and Windows 8

NuGet package for Windows Phone 7.5 and 8

“Pipeline” model for filters, mocks, and more

Page 14: Networking in Windows Phone 8

IXmlHttpRequest2

Mature COM API

Built in to Windows 8 and Windows Phone 8

Only HTTP stack available to native

Page 15: Networking in Windows Phone 8

DEMOHTTP APIs

Page 16: Networking in Windows Phone 8

Socket and Proximity APIs

Page 17: Networking in Windows Phone 8

WinRT Sockets

Simple, modern API based on async pattern

Built in to Windows 8 and Windows Phone 8

Stream- and Datagram- based (no WebSockets on Phone)

Support for client and server scenarios

Page 18: Networking in Windows Phone 8

DEMOStreamSocket

Page 19: Networking in Windows Phone 8

Proximity

Abstraction over NFC, Bluetooth, and WiFi

Built in to Windows 8 and Windows Phone 8

Enables P2P gaming, transfers, etc. (NFC has other uses)

Once connected, uses StreamSocket for communication

Page 20: Networking in Windows Phone 8

Cinemagraph by

NokiaProximity Demo

Page 21: Networking in Windows Phone 8

Proximity Flowchart - Host

Start

Look for peers

Tap other phone

Magic Happens

Connected StreamSocke

t

Connect to peer

Browse for peers

Tap + Play

Page 22: Networking in Windows Phone 8

Proximity Flowchart - Client

Start

Launched via tap

Magic Happens

Connected StreamSocke

t

Browse for peers

Tap + Play

Wait for peer

Connect to peer

Page 23: Networking in Windows Phone 8

DEMOProximity

Page 24: Networking in Windows Phone 8

Tips and Tricks

Page 25: Networking in Windows Phone 8

Tips from today

Setup your dev machine for each new project

Use the pre-release version of WebAPI Client Libraries

Plan your proximity connection experience before you code

Hookup PeerFinder events before calling Start()

Page 26: Networking in Windows Phone 8

Tips from today

Remove <meta> tags for WebBrowser.NavigateToString

Copy the Windows SDK code for IXmlHttpRequest2Always code your web sites in orange Comic Sans MS

Page 27: Networking in Windows Phone 8

Feed Reader by Sam Jarawan

HttpWebRequest works; use HttpClient if rebuilding today

Prefer Json .NET over built-in serializer for complex objects

Consider WebBrowser vs custom XAML UX trade-off

Page 28: Networking in Windows Phone 8

Engadget

Uses background agent to pre-load data

Great for jumping on an aeroplane or slow connections

Also just a great UX in general vs. basic web browser

Page 29: Networking in Windows Phone 8

Other Tips from Popular Apps

Build a priority queue for requests if you have lots going on

Use the new HttpClient.Compression NuGet package

Validate your URIs if dynamically generating them

Use network simulator in Visual Studio

Page 30: Networking in Windows Phone 8

Wrap-Up

Page 31: Networking in Windows Phone 8

Agenda

HTTP – HttpClient (managed); IXmlHttpRequest2 (native)

Sockets – WinRT Sockets

Proximity – Browse vs. Tap; PeerFinder & WinRT Sockets

Tips and Tricks – dev setup, JSON, compression, agents

and always use Comic Sans MS

Page 32: Networking in Windows Phone 8

Other Resources

2-211 Native Code: Tim Laverty - South 102 @ 10:302-212 App2App: Sean McKenna - South 222 @ 2:002-220 Maps: Mike O’Malley - Here (North 134) @ 2:00

2-215 Build for Both: Matt Hidinger - View online3-548 Phone + Azure: Yvor Georgiev - View online4-092 WinRT HttpClient: Peter Smith - View online3-057 Networking: Tim Laverty (//Build/ 2012) - View online

Page 33: Networking in Windows Phone 8

Evaluate this session

Scan this QR code to evaluate this session and be automatically entered in a drawing to win a prize!

Page 34: Networking in Windows Phone 8

© 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.


Recommended