语言

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 属性值所做的任何更改。 因此,如果需要对 NoDelay、OutboundBufferSizeInBytes、ProxyCredential、ServerCredential 或 SupportedProtocols 属性进行更改,则必须在成功调用 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 客户端证书
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

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

适用于