slide1 n.
Download
Skip this Video
Loading SlideShow in 5 Seconds..
Universal APIs PowerPoint Presentation
Download Presentation
Universal APIs

Loading in 2 Seconds...

play fullscreen
1 / 10

Universal APIs

0 Views Download Presentation
Download Presentation

Universal APIs

- - - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript

  1. Universal APIs Windows Phone 8.x + Windows 8.x

  2. Windows.Networking.Proximity.ProximityDevice “Makes your app able to communicate with other devices within an approximate range of 3–4 centimeters, and exchange a small payload of data during the tap.”

  3. ProximityDevice - Receiving ProximityDevice device = ProximityDevice.GetDefault(); // Make sure NFC is supported if (device!= null) { long Id = device.SubscribeForMessage ("Windows.SampleMessageType", messageReceived); Debug.WriteLine("Published Message. ID is {0}", Id); // Store the unique message Id so that it // can be used to stop subscribing for this message type } private void messageReceived(ProximityDevice sender, ProximityMessage message) { Debug.WriteLine("Received from {0}:'{1}'", sender.DeviceId, message.DataAsString); }

  4. ProximityDevice - Sending

  5. Windows.Networking.Proximity.PeerFinder “Lets you discover another instance of your app on a nearby device and create a socket connection between the peer apps by using a tap gesture, or by browsing. A peer app is another instance of an app that is running on another device.”

  6. PeerFinder – Finding other Windows Phone peers ProximityDevice device = ProximityDevice.GetDefault(); // Make sure NFC is supported if (device!= null) { PeerFinder.TriggeredConnectionStateChanged += OnTriggeredConnectionStateChanged; // Start finding peer apps, while making this app discoverable by peers PeerFinder.Start(); }

  7. PeerFinder – Finding other Windows Phone peers StreamSocket _streamSocket; void OnTriggeredConnectionStateChanged(object sender, TriggeredConnectionStateChangedEventArgsargs) { switch (args.State) { case TriggeredConnectState.Listening: // Connecting as host break; case TriggeredConnectState.PeerFound: // Proximity gesture is complete and user can pull their devices away. // Remaining work is to establish the connection using a different //transport, like TCP/IP or Bluetooth break;

  8. PeerFinder – Finding other Windows Phone peers case TriggeredConnectState.Connecting: // Connecting as a client break; case TriggeredConnectState.Completed: // Connection completed, retrieve the socket over which to communicate _streamSocket = args.Socket; break; case TriggeredConnectState.Canceled: break; case TriggeredConnectState.Failed: // Connection was unsuccessful break; } }