Share via


WiFiDirectServiceAdvertiser Class

Definition

Represents a Service Advertiser. This class is used by code on a device that advertises Wi-Fi Direct Services, to advertise the service.

public ref class WiFiDirectServiceAdvertiser sealed
/// [Windows.Foundation.Metadata.Activatable(Windows.Devices.WiFiDirect.Services.IWiFiDirectServiceAdvertiserFactory, 65536, Windows.Foundation.UniversalApiContract)]
/// [Windows.Foundation.Metadata.ContractVersion(Windows.Foundation.UniversalApiContract, 65536)]
/// [Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
class WiFiDirectServiceAdvertiser final
/// [Windows.Foundation.Metadata.ContractVersion(Windows.Foundation.UniversalApiContract, 65536)]
/// [Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
/// [Windows.Foundation.Metadata.Activatable(Windows.Devices.WiFiDirect.Services.IWiFiDirectServiceAdvertiserFactory, 65536, "Windows.Foundation.UniversalApiContract")]
class WiFiDirectServiceAdvertiser final
[Windows.Foundation.Metadata.Activatable(typeof(Windows.Devices.WiFiDirect.Services.IWiFiDirectServiceAdvertiserFactory), 65536, typeof(Windows.Foundation.UniversalApiContract))]
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.Foundation.UniversalApiContract), 65536)]
[Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
public sealed class WiFiDirectServiceAdvertiser
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.Foundation.UniversalApiContract), 65536)]
[Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
[Windows.Foundation.Metadata.Activatable(typeof(Windows.Devices.WiFiDirect.Services.IWiFiDirectServiceAdvertiserFactory), 65536, "Windows.Foundation.UniversalApiContract")]
public sealed class WiFiDirectServiceAdvertiser
function WiFiDirectServiceAdvertiser(serviceName)
Public NotInheritable Class WiFiDirectServiceAdvertiser
Inheritance
Object Platform::Object IInspectable WiFiDirectServiceAdvertiser
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.)

The service name is set in the WiFiDirectServiceAdvertiser constructor. Service names are UTF-8 strings no more than 255 characters long. It is recommended that names use reverse domain name notation, where the service owner's DNS name (such as "contoso.com") is reversed and used as the beginning of the service name (such as "com.contoso.serviceX"). This convention is intended to make it easy to choose unique service names. Service names that start with "org.wi-fi.wfds" are reserved for use by the Wi-Fi Alliance, and you may not use such names for your service.

Constructors

WiFiDirectServiceAdvertiser(String)

Creates an instance of the WiFiDirectServiceAdvertiser class. To start advertising a Wi-Fi Direct Service, create an instance of this class, set its properties appropriately for your service, and then call its Start method.

Properties

AdvertisementStatus

Gets a value that describes the current status of the advertisement.

AutoAcceptSession

Gets or sets the Auto Accept property for this service advertisement.

CustomServiceStatusCode

Gets or sets a custom service status code. Only valid if the ServiceStatus property value is Custom.

DeferredSessionInfo

Gets or sets the service-specific information that is passed to a session requester when establishing a session will not be completed immediately, as when, for example, the service is waiting for user input to complete the request. A requester should implement a 120 second timeout when its request is deferred.

PreferGroupOwnerMode

Gets or sets a value indicating whether the service requires that it be the Wi-Fi Direct Peer to Peer (P2P) Group Owner.

Being the Group Owner enables the service to exercise more control over the P2P connection configuration and the connection process. For details, see the Wi-Fi Direct P2P Technical Specifications, available from the Wi-Fi Alliance.

PreferredConfigurationMethods

Gets a list (that implements the IVector interface) of preferred session configuration methods. Your code uses IVector operations on the list to add or remove elements from the list.

ServiceError

Gets a specific error code when AdvertisementStatus is Aborted.

ServiceInfo

Gets or sets the service information blob. The format and contents of the blob are determined by the individual service, and are intended to be used by Seekers during service discovery.

ServiceName

Gets the service name.

ServiceNamePrefixes

Gets a list of service name prefixes that should match this service when a seeker is using prefix searching. Your code uses IVector methods to add or remove elements from the list.

ServiceStatus

Gets or sets the service status.

Methods

ConnectAsync(DeviceInformation, String)

Accepts a session request by connecting with the given PIN.

ConnectAsync(DeviceInformation)

Accepts a session request without requiring a PIN.

Start()

Starts advertising the service, using current property values to set the parameters of the advertisement.

Stop()

Stops advertising the service. This does not affect existing sessions that are connected to the service.

Events

AdvertisementStatusChanged

Event raised when the AdvertisementStatus property value changes.

AutoAcceptSessionConnected

Event raised when the service has automatically accepted a session request. Your event handler should establish socket connections for the endpoint pairs listed in the event arguments object.

SessionRequested

Event raised when a Seeker has requested that a session be established with the service associated with this WiFiDirectServiceAdvertiser instance. To accept the request, call WiFiDirectServiceAdvertiser.ConnectAsync in your event handler.

Applies to