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 標頭驗證向 Proxy 伺服器進行驗證的認證。

ServerCredential

用來透過使用 StreamWebSocket 物件的 HTTP 標頭驗證向 WebSocket 伺服器驗證的認證。

SupportedProtocols

取得集合,可用來新增支援子通訊協定的清單,這些子通訊協定將在連接交握期間公告至伺服器。

適用於