proximity sockets: trying to understand how it works. RRS feed

  • Question

  • hello guys.

    I've started looking at the proximity code, but I must admit that I can only look at it because I don't have nfc in my laptop. Now, the question: the docs mention that you connect two devices with a simple tap or by browsing for devices. the browsing part is easy to understand: you list the items and then pull one and pass it to PeerFinder.connectAsync. In this case, the target will get the connectionRequested event fired and it will be able to get info from the origin peer. Is this correct? 

    Now, what I'd like to confirm is the behavior associated with tap.

    From what I've seen, it  looks like I need to call PeerFinder.start to put the app in "listening mode". Then, from within the function that handles the triggerconnectionstatechanged event, I need to get the proximity socket when the state is set to completed:

    function handleChange(e) {
     if( e.state === Windows.Networking.Proximity.TriggeredConnectState.peerFound){
      socket = e.socket;//get proximity socket

    btw, I'm also assuming that getting the socket for sending and receiving data is always done within the triggerconnectionstatechanged event in both cases (ie, whether you connect through connectAsync or by tapping). Am I right?


    Luis Abreu

    Wednesday, April 18, 2012 5:06 PM


All replies