Share via


StreamWebSocketControl Kelas

Definisi

Menyediakan data kontrol soket pada objek 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
Warisan
Object Platform::Object IInspectable StreamWebSocketControl
Atribut
Penerapan

Persyaratan Windows

Rangkaian perangkat
Windows 10 (diperkenalkan dalam 10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (diperkenalkan dalam v1.0)
Kemampuan aplikasi
internetClient privateNetworkClientServer

Keterangan

Kelas StreamWebSocketControl menyediakan akses ke data kontrol soket tingkat lanjut pada objek StreamWebSocket .

Objek StreamWebSocketControl secara otomatis dibuat dengan objek StreamWebSocket induk. Properti StreamWebSocket.Control menyediakan akses ke objek StreamWebSocketControl terkait.

Setiap perubahan pada nilai properti StreamWebSocketControl harus diatur sebelum StreamWebSocket tersambung. Akibatnya jika Anda perlu membuat perubahan pada properti NoDelay, OutboundBufferSizeInBytes, ProxyCredential, ServerCredential, atau SupportedProtocols , maka perubahan ini harus terjadi sebelum panggilan berhasil ke metode ConnectAsync pada StreamWebSocket.

Contoh berikut membuat StreamWebSocket, lalu menunjukkan cara mengatur properti StreamWebSocketControl.NoDelay ke false. (Properti lain mungkin diatur dengan cara yang sama.) Setelah ini selesai, aplikasi dapat menghubungkan 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.

Untuk informasi selengkapnya tentang menggunakan StreamWebSocketControl, lihat Cara menggunakan kontrol WebSocket tingkat lanjut.

Riwayat versi

Versi Windows Versi SDK Nilai ditambahkan
1607 14393 IgnorableServerCertificateErrors
1709 16299 ActualUnsolicitedPongInterval
1709 16299 ClientCertificate
1709 16299 DesiredUnsolicitedPongInterval

Properti

ActualUnsolicitedPongInterval

Memungkinkan aplikasi untuk mendapatkan interval PONG WebSocket yang tidak diminta yang sebenarnya.

ClientCertificate

Mendapatkan sertifikat yang disediakan oleh klien ketika koneksi WebSocket aman telah dibuat.

DesiredUnsolicitedPongInterval

Memungkinkan aplikasi untuk mendapatkan dan mengatur interval PONG WebSocket yang tidak diminta yang diinginkan.

IgnorableServerCertificateErrors

Mendapatkan daftar kesalahan sertifikat server yang dapat diabaikan. Dapatkan daftar ini dan tambahkan nilai ChainValidationResult untuk kesalahan sertifikat server yang ingin Anda abaikan selama proses validasi sertifikat server WebSocket (protokol wss:// ) yang aman.

NoDelay

Nilai yang menunjukkan apakah algoritma Nagle digunakan pada objek StreamWebSocket .

OutboundBufferSizeInBytes

Ukuran, dalam byte, dari buffer kirim yang akan digunakan untuk mengirim data pada objek StreamWebSocket .

ProxyCredential

Kredensial yang digunakan untuk mengautentikasi ke server proksi melalui autentikasi header HTTP menggunakan objek StreamWebSocket .

ServerCredential

Info masuk yang digunakan untuk mengautentikasi ke server WebSocket melalui autentikasi header HTTP menggunakan objek StreamWebSocket .

SupportedProtocols

Mendapatkan koleksi yang dapat digunakan untuk menambahkan daftar sub-protokol yang didukung yang akan diiklankan ke server selama jabat tangan koneksi.

Berlaku untuk