WiFiDirectServiceAdvertiser WiFiDirectServiceAdvertiser WiFiDirectServiceAdvertiser 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 : sealed class WiFiDirectServiceAdvertiser : IWiFiDirectServiceAdvertiserpublic sealed class WiFiDirectServiceAdvertiser : IWiFiDirectServiceAdvertiserPublic NotInheritable Class WiFiDirectServiceAdvertiser Implements IWiFiDirectServiceAdvertiser// You can use this class in JavaScript.
Attributes
Windows 10 requirements
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.)

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) WiFiDirectServiceAdvertiser(String) WiFiDirectServiceAdvertiser(String) 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.

public : WiFiDirectServiceAdvertiser(PlatForm::String serviceName)public WiFiDirectServiceAdvertiser(String serviceName)Public Sub New(serviceName As String)// You can use this method in JavaScript.
Parameters
serviceName
PlatForm::String String String String

The name of the service to be advertised. 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.

Properties

AdvertisementStatus AdvertisementStatus AdvertisementStatus AdvertisementStatus

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

public : WiFiDirectServiceAdvertisementStatus AdvertisementStatus { get; }public WiFiDirectServiceAdvertisementStatus AdvertisementStatus { get; }Public ReadOnly Property AdvertisementStatus As WiFiDirectServiceAdvertisementStatus// You can use this property in JavaScript.

AutoAcceptSession AutoAcceptSession AutoAcceptSession AutoAcceptSession

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

public : PlatForm::Boolean AutoAcceptSession { get; set; }public bool AutoAcceptSession { get; set; }Public ReadWrite Property AutoAcceptSession As bool// You can use this property in JavaScript.
Value
PlatForm::Boolean bool bool bool

When true, then the service automatically accepts all requests from service seekers to establish a session. If this value is false, then the service must actively accept a session request when the SessionRequested event is raised.

CustomServiceStatusCode CustomServiceStatusCode CustomServiceStatusCode CustomServiceStatusCode

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

public : unsigned int CustomServiceStatusCode { get; set; }public uint CustomServiceStatusCode { get; set; }Public ReadWrite Property CustomServiceStatusCode As uint// You can use this property in JavaScript.
Value
unsigned int uint uint uint

If ServiceStatus is set to Custom, this property is the custom status value. Custom values must be in the range 2 - 255.

DeferredSessionInfo DeferredSessionInfo DeferredSessionInfo 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.

public : IBuffer DeferredSessionInfo { get; set; }public IBuffer DeferredSessionInfo { get; set; }Public ReadWrite Property DeferredSessionInfo As IBuffer// You can use this property in JavaScript.
Value
IBuffer IBuffer IBuffer IBuffer

The information to be sent to the session requester. Format is service-specific, and total size cannot exceed 144 bytes.

PreferGroupOwnerMode PreferGroupOwnerMode PreferGroupOwnerMode 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.

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

If true, the service must be the Group Owner (GO) of the Peer to Peer (P2P) connection between seeker and service. If false, the service will accept connections whether it is the GO or not.

PreferredConfigurationMethods PreferredConfigurationMethods PreferredConfigurationMethods 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.

public : IVector<WiFiDirectServiceConfigurationMethod> PreferredConfigurationMethods { get; }public IList<WiFiDirectServiceConfigurationMethod> PreferredConfigurationMethods { get; }Public ReadOnly Property PreferredConfigurationMethods As IList<WiFiDirectServiceConfigurationMethod>// You can use this property in JavaScript.
Value
IVector<WiFiDirectServiceConfigurationMethod> IList<WiFiDirectServiceConfigurationMethod> IList<WiFiDirectServiceConfigurationMethod> IList<WiFiDirectServiceConfigurationMethod>

An ordered list of enumeration values indicating preferred configuration methods. The earlier a configuration method appears in the list, the higher the preference for using that method when configuring sessions with this advertiser.

ServiceError ServiceError ServiceError ServiceError

Gets a specific error code when AdvertisementStatus is Aborted.

public : WiFiDirectServiceError ServiceError { get; }public WiFiDirectServiceError ServiceError { get; }Public ReadOnly Property ServiceError As WiFiDirectServiceError// You can use this property in JavaScript.
Value
WiFiDirectServiceError WiFiDirectServiceError WiFiDirectServiceError WiFiDirectServiceError

An enumeration value that gives a more specific cause for AdvertisementStatus being Aborted.

ServiceInfo ServiceInfo ServiceInfo 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.

public : IBuffer ServiceInfo { get; set; }public IBuffer ServiceInfo { get; set; }Public ReadWrite Property ServiceInfo As IBuffer// You can use this property in JavaScript.
Value
IBuffer IBuffer IBuffer IBuffer

The service information blob.

ServiceName ServiceName ServiceName ServiceName

Gets the service name.

public : PlatForm::String ServiceName { get; }public string ServiceName { get; }Public ReadOnly Property ServiceName As string// You can use this property in JavaScript.
Value
PlatForm::String string string string

The service name.

ServiceNamePrefixes ServiceNamePrefixes ServiceNamePrefixes 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.

public : IVector<string> ServiceNamePrefixes { get; }public IList<string> ServiceNamePrefixes { get; }Public ReadOnly Property ServiceNamePrefixes As IList<string>// You can use this property in JavaScript.
Value
IVector<PlatForm::String> IList<string> IList<string> IList<string>

The list of prefixes. Prefix values

ServiceStatus ServiceStatus ServiceStatus ServiceStatus

Gets or sets the service status.

public : WiFiDirectServiceStatus ServiceStatus { get; set; }public WiFiDirectServiceStatus ServiceStatus { get; set; }Public ReadWrite Property ServiceStatus As WiFiDirectServiceStatus// You can use this property in JavaScript.
Value
WiFiDirectServiceStatus WiFiDirectServiceStatus WiFiDirectServiceStatus WiFiDirectServiceStatus

An enumeration value that corresponds to the service status. Note that if this value is Custom, then the CustomServiceStatusCode property gives the actual custom status code value.

Methods

ConnectAsync(DeviceInformation) ConnectAsync(DeviceInformation) ConnectAsync(DeviceInformation) ConnectAsync(DeviceInformation)

Accepts a session request without requiring a PIN.

public : IAsyncOperation<WiFiDirectServiceSession> ConnectAsync(DeviceInformation deviceInfo)public IAsyncOperation<WiFiDirectServiceSession> ConnectAsync(DeviceInformation deviceInfo)Public Function ConnectAsync(deviceInfo As DeviceInformation) As IAsyncOperation( Of WiFiDirectServiceSession )// You can use this method in JavaScript.
Parameters
Returns

An asynchronous connection operation. On successful completion, returns an object that describes the session that has been created.

See Also

ConnectAsync(DeviceInformation, String) ConnectAsync(DeviceInformation, String) ConnectAsync(DeviceInformation, String) ConnectAsync(DeviceInformation, String)

Accepts a session request by connecting with the given PIN.

public : IAsyncOperation<WiFiDirectServiceSession> ConnectAsync(DeviceInformation deviceInfo, PlatForm::String pin)public IAsyncOperation<WiFiDirectServiceSession> ConnectAsync(DeviceInformation deviceInfo, String pin)Public Function ConnectAsync(deviceInfo As DeviceInformation, pin As String) As IAsyncOperation( Of WiFiDirectServiceSession )// You can use this method in JavaScript.
Parameters
pin
PlatForm::String String String String

The PIN to be used to configure the session.

Returns

An asynchronous connection operation. On successful completion, returns an object that describes the session that has been created.

See Also

Start() Start() Start() Start()

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

public : void Start()public void Start()Public Function Start() As void// You can use this method in JavaScript.

Stop() Stop() Stop() Stop()

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

public : void Stop()public void Stop()Public Function Stop() As void// You can use this method in JavaScript.

Events

AdvertisementStatusChanged AdvertisementStatusChanged AdvertisementStatusChanged AdvertisementStatusChanged

Event raised when the AdvertisementStatus property value changes.

public : event TypedEventHandler AdvertisementStatusChanged<WiFiDirectServiceAdvertiser,  object>public event TypedEventHandler AdvertisementStatusChanged<WiFiDirectServiceAdvertiser,  object>Public Event AdvertisementStatusChanged<WiFiDirectServiceAdvertiser,  object>// You can use this event in JavaScript.

AutoAcceptSessionConnected AutoAcceptSessionConnected AutoAcceptSessionConnected 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.

public : event TypedEventHandler AutoAcceptSessionConnected<WiFiDirectServiceAdvertiser,  WiFiDirectServiceAutoAcceptSessionConnectedEventArgs>public event TypedEventHandler AutoAcceptSessionConnected<WiFiDirectServiceAdvertiser,  WiFiDirectServiceAutoAcceptSessionConnectedEventArgs>Public Event AutoAcceptSessionConnected<WiFiDirectServiceAdvertiser,  WiFiDirectServiceAutoAcceptSessionConnectedEventArgs>// You can use this event in JavaScript.

SessionRequested SessionRequested SessionRequested 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.

public : event TypedEventHandler SessionRequested<WiFiDirectServiceAdvertiser,  WiFiDirectServiceSessionRequestedEventArgs>public event TypedEventHandler SessionRequested<WiFiDirectServiceAdvertiser,  WiFiDirectServiceSessionRequestedEventArgs>Public Event SessionRequested<WiFiDirectServiceAdvertiser,  WiFiDirectServiceSessionRequestedEventArgs>// You can use this event in JavaScript.