WiFiDirectService Class

Definition

Represents a Wi-Fi Direct service. This class is used by code on a device that seeks to use a Wi-Fi Direct Service, to establish a Wi-Fi Direct Service session with the service provider.

public ref class WiFiDirectService sealed
/// [Windows.Foundation.Metadata.ContractVersion(Windows.Foundation.UniversalApiContract, 65536)]
/// [Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
class WiFiDirectService final
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.Foundation.UniversalApiContract), 65536)]
[Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
public sealed class WiFiDirectService
Public NotInheritable Class WiFiDirectService
Inheritance
Object Platform::Object IInspectable WiFiDirectService
Attributes

Windows requirements

Device family
Windows 10 (introduced in 10.0.10240.0 - for Xbox, see UWP features that aren't yet supported on Xbox)
API contract
Windows.Foundation.UniversalApiContract (introduced in v1.0)

Remarks

This is one of several classes that support connecting two devices with a preference for which device should be the Group Owner. See the Windows.Devices.WiFiDirect.Service topic for a discussion of device pairing and how it can cause the Group Owner preference to be ignored (and how to fix that.)

Your code does not instantiate this class directly. Instead, your code follows this process to get an instance of this class and use it to establish a Wi-Fi Direct Service session.

  1. Use one of the GetSelector methods to get a query string for a particular service
  2. Create a DeviceWatcher that watches for Advertisers that match the query string. When an Advertiser is found, decide whether to use that Advertiser, either programmatically or by asking the user to indicate a choice.
  3. Once your Seeker has identified the desired service advertiser, call the static FromIdAsync method with the Device ID of the chosen advertiser device. FromIdAsync retrieves an instance of WiFiDirectService for the requested service on the requested device.
  4. Proceed to establish a session by calling WiFiDirectService.ConnectAsync.

Properties

PreferGroupOwnerMode

Gets or sets a value specifying whether the service instance should choose Wi-Fi Direct Point to Point (P2P) Group Owner (GO) mode.

RemoteServiceInfo

Gets the service information blob from this service instance.

ServiceError

Error information about the latest attempt to connect to the service.

SessionInfo

Gets or sets app-specific session information passed to the server when initiating a session.

SupportedConfigurationMethods

Gets a list of supported configuration methods, ordered by preference. Your code uses IVector operations to modify the contents of the list.

Methods

ConnectAsync()

Initiates the establishment of a service session with the Wi-Fi Direct Service represented by this instance.

ConnectAsync(String)

Initiates the establishment of a service session with the Wi-Fi Direct Service represented by this instance, using a PIN to configure the session.

FromIdAsync(String)

Static method that retrieves a WiFiDirectService instance for a Wi-Fi Direct Service offered by the device with a given device ID.

GetProvisioningInfoAsync(WiFiDirectServiceConfigurationMethod)

Asynchronously retrieves Wi-Fi Direct Service session provisioning information.

GetSelector(String)

Gets an Advanced Query Syntax (AQS) string to be used to find Wi-Fi Direct Service advertisers for a particular service.

GetSelector(String, IBuffer)

Gets an Advanced Query Syntax (AQS) string to be used to find Wi-Fi Direct Service advertisers for a particular service, where a given byte sequence appears in the advertiser's service information blob.

Events

SessionDeferred

Event raised when a session request has been deferred. Note that this does not mean that the request has failed or been denied. It is a notification that the server is performing a long operation, such as waiting for a user to enter a PIN. The seeker that receives this message should begin a 120-second wait before it times out the session request, to give the server time to complete its operation. The event arguments include a buffer supplied by the server in the deferral notification with additional information.

Applies to