Jaa


WebSocketKeepAlive Class

Definition

Provides the ability to send a WebSocket protocol keep-alive on a connected WebSocket.

public ref class WebSocketKeepAlive sealed : IBackgroundTask
/// [Windows.Foundation.Metadata.Activatable(65536, Windows.Foundation.UniversalApiContract)]
/// [Windows.Foundation.Metadata.ContractVersion(Windows.Foundation.UniversalApiContract, 65536)]
/// [Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
/// [Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
class WebSocketKeepAlive final : IBackgroundTask
/// [Windows.Foundation.Metadata.ContractVersion(Windows.Foundation.UniversalApiContract, 65536)]
/// [Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
/// [Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
/// [Windows.Foundation.Metadata.Activatable(65536, "Windows.Foundation.UniversalApiContract")]
class WebSocketKeepAlive final : IBackgroundTask
[Windows.Foundation.Metadata.Activatable(65536, typeof(Windows.Foundation.UniversalApiContract))]
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.Foundation.UniversalApiContract), 65536)]
[Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
[Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
public sealed class WebSocketKeepAlive : IBackgroundTask
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.Foundation.UniversalApiContract), 65536)]
[Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
[Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
[Windows.Foundation.Metadata.Activatable(65536, "Windows.Foundation.UniversalApiContract")]
public sealed class WebSocketKeepAlive : IBackgroundTask
Public NotInheritable Class WebSocketKeepAlive
Implements IBackgroundTask
Inheritance
Object Platform::Object IInspectable WebSocketKeepAlive
Attributes
Implements

Windows requirements

Device family
Windows 10 (introduced in 10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (introduced in v1.0)

Remarks

The WebSocketKeepAlive class is used in conjunction with the ControlChannelTrigger class and related interfaces to enable real-time network status and triggers for the StreamWebSocket and MessageWebSocket classes. Control channel triggers are used by long-running network apps to minimize network and system resource usage. Network triggers allow an app to drop to a low-power mode for periods of time while still keeping established network connections intact but in a low-power state. An app can set a keep-alive trigger used by the system for when the app should wake up and send a WebSocket keep-alive packet.

A UWP app is normally suspended when it is no longer in the foreground. There are some exceptions where an app should not be suspended (actively printing, accessing an audio stream, and transferring files in the background, for example). The ControlChannelTrigger class allows a network app that has established a WebSocket connection to notify the system that the network connection should be kept operational and that the system should wake up the suspended app when network data is received for the app or to send a WebSocket keep-alive packet.

WebSocketKeepAlive is used as the TaskEntryPoint for a keep-alive in ControlChannelTrigger. A developer will need to write code to handle receiving data.

For more information about suspending and waking up an app, How to set background connectivity options.

For more information on the WebSocket keep-alive control frames, see the WebSocket Protocol.

Constructors

WebSocketKeepAlive()

Creates a new WebSocketKeepAlive object.

Methods

Run(IBackgroundTaskInstance)

Sends a WebSocket protocol keep-alive on a connected WebSocket.

Applies to