Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ GetSupportedVersion()

static string System.Net.WebSockets.WebSocketProtocolComponent.GetSupportedVersion ( )
inlinestaticpackage

Definition at line 133 of file WebSocketProtocolComponent.cs.

134 {
135 if (!IsSupported)
136 {
137 HttpWebSocket.ThrowPlatformNotSupportedException_WSPC();
138 }
139 SafeWebSocketHandle webSocketHandle = null;
140 try
141 {
142 int errorCode = global::Interop.WebSocket.WebSocketCreateClientHandle(null, 0u, out webSocketHandle);
143 ThrowOnError(errorCode);
144 if (webSocketHandle == null || webSocketHandle.IsInvalid)
145 {
146 HttpWebSocket.ThrowPlatformNotSupportedException_WSPC();
147 }
148 errorCode = global::Interop.WebSocket.WebSocketBeginClientHandshake(webSocketHandle, IntPtr.Zero, 0u, IntPtr.Zero, 0u, s_initialClientRequestHeaders, (uint)s_initialClientRequestHeaders.Length, out var additionalHeadersPtr, out var additionalHeaderCount);
149 ThrowOnError(errorCode);
150 global::Interop.WebSocket.HttpHeader[] array = MarshalHttpHeaders(additionalHeadersPtr, (int)additionalHeaderCount);
151 string result = null;
152 global::Interop.WebSocket.HttpHeader[] array2 = array;
153 for (int i = 0; i < array2.Length; i++)
154 {
155 global::Interop.WebSocket.HttpHeader httpHeader = array2[i];
156 if (string.Equals(httpHeader.Name, "Sec-WebSocket-Version", StringComparison.OrdinalIgnoreCase))
157 {
158 result = httpHeader.Value;
159 break;
160 }
161 }
162 return result;
163 }
164 finally
165 {
166 webSocketHandle?.Dispose();
167 }
168 }
static readonly global::Interop.WebSocket.HttpHeader[] s_initialClientRequestHeaders
static global::Interop.WebSocket.HttpHeader[] MarshalHttpHeaders(IntPtr nativeHeadersPtr, int nativeHeaderCount)

References System.array, System.Runtime.InteropServices.SafeHandle.Dispose(), System.Net.Equals, System.Net.WebSockets.WebSocketProtocolComponent.IsSupported, System.Net.WebSockets.WebSocketProtocolComponent.MarshalHttpHeaders(), System.Net.WebSockets.WebSocketProtocolComponent.s_initialClientRequestHeaders, System.Net.WebSockets.WebSocketProtocolComponent.ThrowOnError(), System.Net.WebSockets.HttpWebSocket.ThrowPlatformNotSupportedException_WSPC(), and System.IntPtr.Zero.

Referenced by System.Net.WebSockets.WebSocketProtocolComponent.WebSocketProtocolComponent().