EN
Este conteúdo não está disponível em seu idioma, mas aqui está a versão em inglês.

Windows.Networking.Proximity namespace

Applies to Windows and Windows Phone

Contains classes that support connections between devices that are within close range.

Members

The Windows.Networking.Proximity namespace has these types of members:

Classes

The Windows.Networking.Proximity namespace has these classes.

ClassDescription
ConnectionRequestedEventArgs Contains properties that are passed to an application with the ConnectionRequested event.
PeerFinder Enables you to discover other instances of your app on nearby devices and create a socket connection between the peer apps by using a tap gesture or by browsing.
PeerInformation Contains information that identifies a peer.
PeerWatcher Dynamically discovers peer apps within wireless range.
ProximityDevice Enables you to publish messages to proximate devices or subscribe to messages from proximate devices.
ProximityMessage Represents a message that's received from a subscription.
TriggeredConnectionStateChangedEventArgs Contains properties that the TriggeredConnectionStateChanged event passes to an application.

 

Delegates

The Windows.Networking.Proximity namespace has these delegates.

DelegateDescription
DeviceArrivedEventHandler Describes the method that handles the DeviceArrived event.
DeviceDepartedEventHandler Describes the method that handles the DeviceDeparted event.
MessageReceivedHandler Describes the method that will handle the event that's fired when a message that has been subscribed to has been received.
MessageTransmittedHandler Describes the method that will handle the event that's fired when a published message has been transmitted.

 

Enumerations

The Windows.Networking.Proximity namespace has these enumerations.

EnumerationDescription
PeerDiscoveryTypes Indicates which discovery options are available to use with the PeerFinder class.
PeerRole Describes the role of the peer app when connected to multiple peers.
PeerWatcherStatus Describes the status of a PeerWatcher object.
TriggeredConnectState Indicates the current state of a connection to a peer application.

 

Remarks

You can use proximity to connect computers by using a simple tap gesture. If two computers come within 3 centimeters to 4 centimeters of each other, or are tapped together, the operating system of each computer detects the other computer. You can then connect the two computers to share content or publish and subscribe to messages. Proximity also supports discovery of peer devices via Wi-Fi Direct.

Important  

The proximity APIs do not provide authentication, encryption, or message integrity. Do not use proximity to exchange user sensitive information such as passwords, financial data, text messages, email, photographs, or government id numbers.

Examples

This example shows how you can use the ProximityDevice class to determine when a device enters and leaves proximity.


function id(elementId) {
    return document.getElementById(elementId);
}

var proximityDevice;

function initializeProximityDevice() {
    proximityDevice = Windows.Networking.Proximity.ProximityDevice.getDefault();

    if (proximityDevice) {
        proximityDevice.addEventListener("devicearrived", proximityDeviceArrived);
        proximityDevice.addEventListener("devicedeparted", proximityDeviceDeparted);

        id("messageDiv").innerHTML += "Proximity device initialized.<br />";
    }
    else {
        id("messageDiv").innerHTML += "Failed to initialized proximity device.<br />";
    }
}

function proximityDeviceArrived(device) {
    id("messageDiv").innerHTML += "Proximate device arrived. id = " + device.deviceId + "<br />";
}

function proximityDeviceDeparted(device) {
    id("messageDiv").innerHTML += "Proximate device departed. id = " + device.deviceId + "<br />";
}


Requirements

Minimum supported client

Windows 8

Minimum supported server

Windows Server 2012

Minimum supported phone

Windows Phone 8

Namespace

Windows.Networking.Proximity
Windows::Networking::Proximity [C++]

Metadata

Windows.winmd

Capabilities

proximity
ID_CAP_PROXIMITY [Windows Phone]

See also

Proximity and Tapping (JavaScript)
Proximity and Tapping (C#/VB/C++)
Samples
Proximity sample

 

 

Mostrar:
© 2014 Microsoft