WiFiDirectService
WiFiDirectService
WiFiDirectService
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 : sealed class WiFiDirectService : IWiFiDirectServicepublic sealed class WiFiDirectService : IWiFiDirectServicePublic NotInheritable Class WiFiDirectService Implements IWiFiDirectService// You can use this class in JavaScript.
- Attributes
| Device family |
Windows 10 (introduced v10.0.10240.0 - for Xbox, see UWP features that aren't yet supported on Xbox)
|
| API contract |
Windows.Foundation.UniversalApiContract (introduced v1)
|
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.
- Use one of the GetSelector methods to get a query string for a particular service
- 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.
- 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.
- Proceed to establish a session by calling WiFiDirectService.ConnectAsync.
Properties
PreferGroupOwnerMode PreferGroupOwnerMode PreferGroupOwnerMode PreferGroupOwnerMode
Gets or sets a value specifying whether the service instance should choose Wi-Fi Direct Point to Point (P2P) Group Owner (GO) mode.
public : PlatForm::Boolean PreferGroupOwnerMode { get; set; }public bool PreferGroupOwnerMode { get; set; }Public ReadWrite Property PreferGroupOwnerMode As bool// You can use this property in JavaScript.
- Value
- PlatForm::Boolean bool bool bool
When true, prefer GO mode.
RemoteServiceInfo RemoteServiceInfo RemoteServiceInfo RemoteServiceInfo
Gets the service information blob from this service instance.
public : IBuffer RemoteServiceInfo { get; }public IBuffer RemoteServiceInfo { get; }Public ReadOnly Property RemoteServiceInfo As IBuffer// You can use this property in JavaScript.
ServiceError ServiceError ServiceError ServiceError
Error information about the latest attempt to connect to the service.
public : WiFiDirectServiceError ServiceError { get; }public WiFiDirectServiceError ServiceError { get; }Public ReadOnly Property ServiceError As WiFiDirectServiceError// You can use this property in JavaScript.
An enumeration value specifying the detailed reason for the failure.
SessionInfo SessionInfo SessionInfo SessionInfo
Gets or sets app-specific session information passed to the server when initiating a session.
public : IBuffer SessionInfo { get; set; }public IBuffer SessionInfo { get; set; }Public ReadWrite Property SessionInfo As IBuffer// You can use this property in JavaScript.
Session information. Format is determined by the individual service. Set this property before calling ConnectAsync.
SupportedConfigurationMethods SupportedConfigurationMethods SupportedConfigurationMethods SupportedConfigurationMethods
Gets a list of supported configuration methods, ordered by preference. Your code uses IVector operations to modify the contents of the list.
public : IVectorView<WiFiDirectServiceConfigurationMethod> SupportedConfigurationMethods { get; }public IReadOnlyList<WiFiDirectServiceConfigurationMethod> SupportedConfigurationMethods { get; }Public ReadOnly Property SupportedConfigurationMethods As IReadOnlyList<WiFiDirectServiceConfigurationMethod>// You can use this property in JavaScript.
- Value
- IVectorView<WiFiDirectServiceConfigurationMethod> IReadOnlyList<WiFiDirectServiceConfigurationMethod> IReadOnlyList<WiFiDirectServiceConfigurationMethod> IReadOnlyList<WiFiDirectServiceConfigurationMethod>
Ordered list of configuration method enumeration values.
Methods
ConnectAsync() ConnectAsync() ConnectAsync() ConnectAsync()
Initiates the establishment of a service session with the Wi-Fi Direct Service represented by this instance.
public : IAsyncOperation<WiFiDirectServiceSession> ConnectAsync()public IAsyncOperation<WiFiDirectServiceSession> ConnectAsync()Public Function ConnectAsync() As IAsyncOperation( Of WiFiDirectServiceSession )// You can use this method in JavaScript.
An asynchronous connection operation. When successfully completed, returns an object that represents the session that has been established.
- See Also
ConnectAsync(String) ConnectAsync(String) ConnectAsync(String) 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.
public : IAsyncOperation<WiFiDirectServiceSession> ConnectAsync(PlatForm::String pin)public IAsyncOperation<WiFiDirectServiceSession> ConnectAsync(String pin)Public Function ConnectAsync(pin As String) As IAsyncOperation( Of WiFiDirectServiceSession )// You can use this method in JavaScript.
- pin
- PlatForm::String String String String
The PIN to be used to configure the connection.
An asynchronous connection operation. When successfully completed, returns an object that represents the session that has been established.
- See Also
FromIdAsync(String) FromIdAsync(String) FromIdAsync(String) FromIdAsync(String)
Static method that retrieves a WiFiDirectService instance for a Wi-Fi Direct Service offered by the device with a given device ID.
public : static IAsyncOperation<WiFiDirectService> FromIdAsync(PlatForm::String deviceId)public static IAsyncOperation<WiFiDirectService> FromIdAsync(String deviceId)Public Static Function FromIdAsync(deviceId As String) As IAsyncOperation( Of WiFiDirectService )// You can use this method in JavaScript.
- deviceId
- PlatForm::String String String String
Device ID of the device that advertises the desired Wi-Fi Direct Service.
An asynchronous retrieval operation. On successful completion, returns an instance of WiFiDirectService specific to the desired service instance, advertised by the indicated device.
Remarks
Your code retrieves Device IDs for service advertisers by using the search and enumeration methods in the Windows.Devices.Enumeration namespace.
GetProvisioningInfoAsync(WiFiDirectServiceConfigurationMethod) GetProvisioningInfoAsync(WiFiDirectServiceConfigurationMethod) GetProvisioningInfoAsync(WiFiDirectServiceConfigurationMethod) GetProvisioningInfoAsync(WiFiDirectServiceConfigurationMethod)
Asynchronously retrieves Wi-Fi Direct Service session provisioning information.
public : IAsyncOperation<WiFiDirectServiceProvisioningInfo> GetProvisioningInfoAsync(WiFiDirectServiceConfigurationMethod selectedConfigurationMethod)public IAsyncOperation<WiFiDirectServiceProvisioningInfo> GetProvisioningInfoAsync(WiFiDirectServiceConfigurationMethod selectedConfigurationMethod)Public Function GetProvisioningInfoAsync(selectedConfigurationMethod As WiFiDirectServiceConfigurationMethod) As IAsyncOperation( Of WiFiDirectServiceProvisioningInfo )// You can use this method in JavaScript.
- selectedConfigurationMethod
- WiFiDirectServiceConfigurationMethod WiFiDirectServiceConfigurationMethod WiFiDirectServiceConfigurationMethod WiFiDirectServiceConfigurationMethod
The preferred method of configuring the session.
An asynchronous retrieval operation. On successful completion, returns provisioning information.
GetSelector(String) GetSelector(String) GetSelector(String) GetSelector(String)
Gets an Advanced Query Syntax (AQS) string to be used to find Wi-Fi Direct Service advertisers for a particular service.
public : static PlatForm::String GetSelector(PlatForm::String serviceName)public static string GetSelector(String serviceName)Public Static Function GetSelector(serviceName As String) As string// You can use this method in JavaScript.
- serviceName
- PlatForm::String String String String
The service name to be found.
The AQS string for the requested advertiser query.
Remarks
Your code uses AQS strings with the search and enumeration methods in the Windows.Devices.Enumeration namespace.
- See Also
GetSelector(String, IBuffer) GetSelector(String, IBuffer) GetSelector(String, IBuffer) 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.
public : static PlatForm::String GetSelector(PlatForm::String serviceName, IBuffer serviceInfoFilter)public static string GetSelector(String serviceName, IBuffer serviceInfoFilter)Public Static Function GetSelector(serviceName As String, serviceInfoFilter As IBuffer) As string// You can use this method in JavaScript.
- serviceName
- PlatForm::String String String String
The service name to be found.
A byte sequence that must be found in the advertiser's service information blob.
The AQS string for the requested advertiser query.
Remarks
Your code uses AQS strings with the search and enumeration methods in the Windows.Devices.Enumeration namespace.
- See Also
Events
SessionDeferred SessionDeferred SessionDeferred 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.
public : event TypedEventHandler SessionDeferred<WiFiDirectService, WiFiDirectServiceSessionDeferredEventArgs>public event TypedEventHandler SessionDeferred<WiFiDirectService, WiFiDirectServiceSessionDeferredEventArgs>Public Event SessionDeferred<WiFiDirectService, WiFiDirectServiceSessionDeferredEventArgs>// You can use this event in JavaScript.