MessageWebSocketControl MessageWebSocketControl MessageWebSocketControl MessageWebSocketControl MessageWebSocketControl Class

Definition

Provides socket control data on a MessageWebSocket.

public : sealed class MessageWebSocketControl : IMessageWebSocketControl, IWebSocketControl, IWebSocketControl2
struct winrt::Windows::Networking::Sockets::MessageWebSocketControl : IMessageWebSocketControl, IWebSocketControl, IWebSocketControl2
public sealed class MessageWebSocketControl : IMessageWebSocketControl, IWebSocketControl, IWebSocketControl2
Public NotInheritable Class MessageWebSocketControl Implements IMessageWebSocketControl, IWebSocketControl, IWebSocketControl2
// This class does not provide a public constructor.
Attributes
Windows 10 requirements
Device family
Windows 10 (introduced v10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v1)

Remarks

The MessageWebSocketControl class provides access to advanced socket control data on a MessageWebSocket object.

A MessageWebSocketControl object is automatically created with the parent MessageWebSocket object. The MessageWebSocket.Control property provides access to the associated MessageWebSocket object.

The SupportedProtocols property gets the value of this property and can be called at any time.

The MessageType property can be changed at any time before or after the MessageWebSocket is connected. This allows an app to switch between binary and UTF-8 messages when needed.

The OutboundBufferSizeInBytes property must be set before the MessageWebSocket is connected. Setting this property after the MessageWebSocket is connected has no effect.

Any changes to the other property values on the MessageWebSocketControl must be set before the DatagramSocket is bound or connected. As a result if you need to make changes to the MaxMessageSize, ProxyCredential, OutboundBufferSizeInBytes, or ServerCredential properties, then these changes must occur before a successful call to the ConnectAsync method on the MessageWebSocket.

The following example creates a MessageWebSocket, and then demonstrates how to set the MessageWebSocketControl.MessageType property to binary. (Other properties may be set in a similar manner.) After this is done, the app can connect the MessageWebSocket.

var clientWebSocket = new Windows.Networking.Sockets.MessageWebSocket();

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

// Set messageType to binary 
clientWebSocket.control.messageType = Windows.Networking.Sockets.SocketMessageType.binary;

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

MessageWebSocket^ clientWebSocket = ref new MessageWebSocket();

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

// Set messageType to binary 
clientWebSocket->Control->MessageType = SocketMessageType::Binary;

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

MessageWebSocket clientWebSocket = new MessageWebSocket();

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

// Set messageType to binary 
clientWebSocket.Control.MessageType = SocketMessageType.Binary;

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

For more information on using MessageWebSocketControl, see How to use advanced WebSocket controls and How to use advanced WebSocket controls .

Properties

ActualUnsolicitedPongInterval ActualUnsolicitedPongInterval ActualUnsolicitedPongInterval ActualUnsolicitedPongInterval ActualUnsolicitedPongInterval

Allows an app to get the actual unsolicited WebSocket PONG interval.

ClientCertificate ClientCertificate ClientCertificate ClientCertificate ClientCertificate

Gets the certificate provided by the client when a secure WebSocket connection has been established.

DesiredUnsolicitedPongInterval DesiredUnsolicitedPongInterval DesiredUnsolicitedPongInterval DesiredUnsolicitedPongInterval DesiredUnsolicitedPongInterval

Allows an app to get and set the desired unsolicited WebSocket PONG interval.

IgnorableServerCertificateErrors IgnorableServerCertificateErrors IgnorableServerCertificateErrors IgnorableServerCertificateErrors IgnorableServerCertificateErrors

Gets a list of ignorable server certificate errors. Get this list and add ChainValidationResult values for server certificate errors that you wish to ignore during the secure WebSocket (wss:// protocol) server certificate validation process.

MaxMessageSize MaxMessageSize MaxMessageSize MaxMessageSize MaxMessageSize

The maximum message size, in bytes, for a WebSocket message to be configured on the MessageWebSocket object.

MessageType MessageType MessageType MessageType MessageType

The WebSocket message type to be configured on a MessageWebSocket object for write operations.

OutboundBufferSizeInBytes OutboundBufferSizeInBytes OutboundBufferSizeInBytes OutboundBufferSizeInBytes OutboundBufferSizeInBytes

The size, in bytes, of the send buffer to be used for sending data on a MessageWebSocket object.

ProxyCredential ProxyCredential ProxyCredential ProxyCredential ProxyCredential

The credential to use to authenticate to the proxy server through HTTP header authentication using a MessageWebSocket object.

ReceiveMode ReceiveMode ReceiveMode ReceiveMode ReceiveMode

Allows clients to control receiving either complete or partial messages.

ServerCredential ServerCredential ServerCredential ServerCredential ServerCredential

The credential to use to authenticate to the WebSocket server through HTTP header authentication using a MessageWebSocket object.

SupportedProtocols SupportedProtocols SupportedProtocols SupportedProtocols SupportedProtocols

Gets a collection that can be used to add a list of supported sub-protocols that will be advertised to the server during the connect handshake.

See Also