StreamWebSocketControl 类

定义

StreamWebSocket 对象上提供套接字控件数据。

public ref class StreamWebSocketControl sealed
public ref class StreamWebSocketControl sealed : IWebSocketControl2
/// [Windows.Foundation.Metadata.ContractVersion(Windows.Foundation.UniversalApiContract, 65536)]
/// [Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
class StreamWebSocketControl final
/// [Windows.Foundation.Metadata.ContractVersion(Windows.Foundation.UniversalApiContract, 65536)]
/// [Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
class StreamWebSocketControl final : IWebSocketControl2
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.Foundation.UniversalApiContract), 65536)]
[Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
public sealed class StreamWebSocketControl
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.Foundation.UniversalApiContract), 65536)]
[Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
public sealed class StreamWebSocketControl : IWebSocketControl2
Public NotInheritable Class StreamWebSocketControl
Public NotInheritable Class StreamWebSocketControl
Implements IWebSocketControl2
继承
Object Platform::Object IInspectable StreamWebSocketControl
属性
实现

Windows 要求

设备系列
Windows 10 (在 10.0.10240.0 中引入)
API contract
Windows.Foundation.UniversalApiContract (在 v1.0 中引入)
应用功能
internetClient privateNetworkClientServer

注解

StreamWebSocketControl 类提供对 StreamWebSocket 对象上高级套接字控件数据的访问权限。

StreamWebSocketControl 对象是使用父 StreamWebSocket 对象自动创建的。 StreamWebSocket.Control 属性提供对关联的 StreamWebSocketControl 对象的访问。

在连接 StreamWebSocket 之前,必须设置对 StreamWebSocketControl 属性值所做的任何更改。 因此,如果需要更改 NoDelayOutboundBufferSizeInBytesProxyCredentialServerCredentialSupportedProtocols 属性,则在成功调用 StreamWebSocket 上的 ConnectAsync 方法之前,必须进行这些更改。

以下示例创建 StreamWebSocket,然后演示如何将 StreamWebSocketControl.NoDelay 属性设置为 false。 (其他属性可能以类似的方式设置。) 完成后,应用可以连接 StreamWebSocket

using Windows.Networking.Sockets;

StreamWebSocket clientWebSocket = new StreamWebSocket();

// Get the current setting for this option.
// This isn't required, but it shows how to get the current setting.
bool currentSetting = clientWebSocket.Control.NoDelay;

// Set NoDelay to false so that the Nagle algorithm is not disabled.
clientWebSocket.Control.NoDelay = false;

// Now you can call the ConnectAsync method to connect the StreamWebSocket.
#include <winrt/Windows.Networking.Sockets.h>
using namespace winrt;
...
Windows::Networking::Sockets::StreamWebSocket clientWebSocket;

// Get the current setting for this option.
// This isn't required, but it shows how to get the current setting.
bool currentSetting{ clientWebSocket.Control().NoDelay() };

// Set NoDelay to false so that the Nagle algorithm is not disabled.
clientWebSocket.Control().NoDelay(false);

// Now you can call the ConnectAsync method to connect the StreamWebSocket.
using namespace Windows::Networking::Sockets;

StreamWebSocket^ clientWebSocket = ref new StreamWebSocket();

// Get the current setting for this option.
// This isn't required, but it shows how to get the current setting .
bool currentSetting = clientWebSocket->Control->NoDelay;

// Set NoDelay to false so that the Nagle algorithm is not disabled.
clientWebSocket->Control->NoDelay = false;

// Now you can call the ConnectAsync method to connect the StreamWebSocket.

有关使用 StreamWebSocketControl 的详细信息,请参阅 如何使用高级 WebSocket 控件

版本历史记录

Windows 版本 SDK 版本 增值
1607 14393 IgnorableServerCertificateErrors
1709 16299 ActualUnsolicitedPongInterval
1709 16299 ClientCertificate
1709 16299 DesiredUnsolicitedPongInterval

属性

ActualUnsolicitedPongInterval

允许应用获取实际未经请求的 WebSocket PONG 间隔。

ClientCertificate

获取建立安全 WebSocket 连接时客户端提供的证书。

DesiredUnsolicitedPongInterval

允许应用获取和设置所需的未经请求的 WebSocket PONG 间隔。

IgnorableServerCertificateErrors

获取可忽略的服务器证书错误的列表。 获取此列表,并添加希望在安全 WebSocket (wss:// 协议) 服务器证书验证过程中忽略的服务器证书错误的 ChainValidationResult 值。

NoDelay

一个 值,该值指示是否在 StreamWebSocket 对象上使用 Nagle 算法。

OutboundBufferSizeInBytes

用于在 StreamWebSocket 对象上发送数据的发送缓冲区的大小(以字节为单位)。

ProxyCredential

用于使用 StreamWebSocket 对象通过 HTTP 标头身份验证向代理服务器进行身份验证的凭据。

ServerCredential

用于使用 StreamWebSocket 对象通过 HTTP 标头身份验证向 WebSocket 服务器进行身份验证的 凭据。

SupportedProtocols

获取一个集合,该集合可用于添加支持子协议的列表,这些协议将在连接握手期间播发到服务器。

适用于