@tsonic/dotnet-pure
Version:
TypeScript type definitions for .NET 10 BCL (Base Class Library) - CLR naming
399 lines (320 loc) • 17.8 kB
TypeScript
// Generated by tsbindgen - Architecture
// Namespace: System.Net.WebSockets
// Assembly: System.Net.HttpListener, System.Net.WebSockets, System.Net.WebSockets.Client
// Branded primitive types are sourced from @tsonic/types
import type { sbyte, byte, short, ushort, int, uint, long, ulong, int128, uint128, half, float, double, decimal, nint, nuint, char } from '@tsonic/types';
// Import types from other namespaces
import type { IEnumerable_1, IReadOnlyDictionary_2 } from "../../System.Collections.Generic/internal/index.js";
import type { NameValueCollection } from "../../System.Collections.Specialized/internal/index.js";
import type { IDictionary } from "../../System.Collections/internal/index.js";
import * as System_ComponentModel_Internal from "../../System.ComponentModel/internal/index.js";
import type { Win32Exception } from "../../System.ComponentModel/internal/index.js";
import * as System_IO_Internal from "../../System.IO/internal/index.js";
import type { SeekOrigin, Stream } from "../../System.IO/internal/index.js";
import type { HttpMessageInvoker, HttpVersionPolicy } from "../../System.Net.Http/internal/index.js";
import type { RemoteCertificateValidationCallback } from "../../System.Net.Security/internal/index.js";
import type { CookieCollection, CookieContainer, HttpStatusCode, ICredentials, IWebProxy } from "../../System.Net/internal/index.js";
import type { MethodBase } from "../../System.Reflection/internal/index.js";
import * as System_Runtime_Serialization_Internal from "../../System.Runtime.Serialization/internal/index.js";
import type { ISerializable, SerializationInfo, StreamingContext } from "../../System.Runtime.Serialization/internal/index.js";
import type { X509CertificateCollection } from "../../System.Security.Cryptography.X509Certificates/internal/index.js";
import type { IPrincipal } from "../../System.Security.Principal/internal/index.js";
import type { Task, Task_1, ValueTask, ValueTask_1 } from "../../System.Threading.Tasks/internal/index.js";
import type { CancellationToken } from "../../System.Threading/internal/index.js";
import * as System_Internal from "../../System/internal/index.js";
import type { ArraySegment_1, AsyncCallback, Boolean as ClrBoolean, Byte, Enum, Exception, IAsyncDisposable, IAsyncResult, IComparable, IConvertible, IDisposable, IFormatProvider, IFormattable, Int32, Int64, ISpanFormattable, Memory_1, Nullable_1, Object as ClrObject, ReadOnlyMemory_1, ReadOnlySpan_1, Span_1, String as ClrString, TimeSpan, Type, TypeCode, Uri, ValueType, Version, Void } from "../../System/internal/index.js";
// CLROf<T> - Maps ergonomic primitives to their CLR types for generic constraints
// This utility is used ONLY in generic type arguments to satisfy CLR interface constraints
// Value positions (parameters, return types) use lowercase primitives for ergonomics
export type CLROf<T> =
T extends sbyte ? System_Internal.SByte :
T extends short ? System_Internal.Int16 :
T extends int ? System_Internal.Int32 :
T extends long ? System_Internal.Int64 :
T extends int128 ? System_Internal.Int128 :
T extends nint ? System_Internal.IntPtr :
T extends byte ? System_Internal.Byte :
T extends ushort ? System_Internal.UInt16 :
T extends uint ? System_Internal.UInt32 :
T extends ulong ? System_Internal.UInt64 :
T extends uint128 ? System_Internal.UInt128 :
T extends nuint ? System_Internal.UIntPtr :
T extends half ? System_Internal.Half :
T extends float ? System_Internal.Single :
T extends double ? System_Internal.Double :
T extends decimal ? System_Internal.Decimal :
T extends char ? System_Internal.Char :
T extends boolean ? System_Internal.Boolean :
T extends string ? System_Internal.String :
T; // Identity fallback for non-primitive types
export enum WebSocketCloseStatus {
NormalClosure = 1000,
EndpointUnavailable = 1001,
ProtocolError = 1002,
InvalidMessageType = 1003,
Empty = 1005,
InvalidPayloadData = 1007,
PolicyViolation = 1008,
MessageTooBig = 1009,
MandatoryExtension = 1010,
InternalServerError = 1011
}
export enum WebSocketError {
Success = 0,
InvalidMessageType = 1,
Faulted = 2,
NativeError = 3,
NotAWebSocket = 4,
UnsupportedVersion = 5,
UnsupportedProtocol = 6,
HeaderError = 7,
ConnectionClosedPrematurely = 8,
InvalidState = 9
}
export enum WebSocketMessageFlags {
None = 0,
EndOfMessage = 1,
DisableCompression = 2
}
export enum WebSocketMessageType {
Text = 0,
Binary = 1,
Close = 2
}
export enum WebSocketState {
None = 0,
Connecting = 1,
Open = 2,
CloseSent = 3,
CloseReceived = 4,
Closed = 5,
Aborted = 6
}
export interface ValueWebSocketReceiveResult$instance {
readonly Count: int;
readonly EndOfMessage: boolean;
readonly MessageType: WebSocketMessageType;
}
export const ValueWebSocketReceiveResult: {
new(count: int, messageType: WebSocketMessageType, endOfMessage: boolean): ValueWebSocketReceiveResult$instance;
};
export type ValueWebSocketReceiveResult = ValueWebSocketReceiveResult$instance;
export interface ClientWebSocket$instance extends WebSocket$instance {
readonly CloseStatus: Nullable_1<WebSocketCloseStatus>;
readonly CloseStatusDescription: string;
HttpResponseHeaders: IReadOnlyDictionary_2<CLROf<string>, IEnumerable_1<CLROf<string>>>;
readonly HttpStatusCode: HttpStatusCode;
readonly Options: ClientWebSocketOptions;
readonly State: WebSocketState;
readonly SubProtocol: string;
Abort(): void;
CloseAsync(closeStatus: WebSocketCloseStatus, statusDescription: string, cancellationToken: CancellationToken): Task;
CloseOutputAsync(closeStatus: WebSocketCloseStatus, statusDescription: string, cancellationToken: CancellationToken): Task;
ConnectAsync(uri: Uri, cancellationToken: CancellationToken): Task;
ConnectAsync(uri: Uri, invoker: HttpMessageInvoker, cancellationToken: CancellationToken): Task;
Dispose(): void;
ReceiveAsync(buffer: ArraySegment_1<CLROf<byte>>, cancellationToken: CancellationToken): Task_1<WebSocketReceiveResult>;
ReceiveAsync(buffer: Memory_1<CLROf<byte>>, cancellationToken: CancellationToken): ValueTask_1<ValueWebSocketReceiveResult>;
ReceiveAsync(buffer: Memory_1<CLROf<byte>>, cancellationToken: CancellationToken): ValueTask_1<ValueWebSocketReceiveResult>;
SendAsync(buffer: ArraySegment_1<CLROf<byte>>, messageType: WebSocketMessageType, endOfMessage: boolean, cancellationToken: CancellationToken): Task;
SendAsync(buffer: ReadOnlyMemory_1<CLROf<byte>>, messageType: WebSocketMessageType, endOfMessage: boolean, cancellationToken: CancellationToken): ValueTask;
SendAsync(buffer: ReadOnlyMemory_1<CLROf<byte>>, messageType: WebSocketMessageType, messageFlags: WebSocketMessageFlags, cancellationToken: CancellationToken): ValueTask;
SendAsync(buffer: ReadOnlyMemory_1<CLROf<byte>>, messageType: WebSocketMessageType, endOfMessage: boolean, cancellationToken: CancellationToken): ValueTask;
SendAsync(buffer: ReadOnlyMemory_1<CLROf<byte>>, messageType: WebSocketMessageType, messageFlags: WebSocketMessageFlags, cancellationToken?: CancellationToken): ValueTask;
}
export const ClientWebSocket: {
new(): ClientWebSocket$instance;
};
export interface __ClientWebSocket$views {
As_IDisposable(): System_Internal.IDisposable$instance;
}
export type ClientWebSocket = ClientWebSocket$instance & __ClientWebSocket$views;
export interface ClientWebSocketOptions$instance {
ClientCertificates: X509CertificateCollection;
CollectHttpResponseDetails: boolean;
Cookies: CookieContainer;
Credentials: ICredentials;
DangerousDeflateOptions: WebSocketDeflateOptions;
HttpVersion: Version;
HttpVersionPolicy: HttpVersionPolicy;
KeepAliveInterval: TimeSpan;
KeepAliveTimeout: TimeSpan;
Proxy: IWebProxy;
RemoteCertificateValidationCallback: RemoteCertificateValidationCallback;
UseDefaultCredentials: boolean;
AddSubProtocol(subProtocol: string): void;
SetBuffer(receiveBufferSize: int, sendBufferSize: int): void;
SetBuffer(receiveBufferSize: int, sendBufferSize: int, buffer: ArraySegment_1<CLROf<byte>>): void;
SetRequestHeader(headerName: string, headerValue: string): void;
}
export const ClientWebSocketOptions: {
new(): ClientWebSocketOptions$instance;
};
export type ClientWebSocketOptions = ClientWebSocketOptions$instance;
export interface HttpListenerWebSocketContext$instance extends WebSocketContext {
readonly CookieCollection: CookieCollection;
readonly Headers: NameValueCollection;
readonly IsAuthenticated: boolean;
readonly IsLocal: boolean;
readonly IsSecureConnection: boolean;
readonly Origin: string;
readonly RequestUri: Uri;
readonly SecWebSocketKey: string;
readonly SecWebSocketProtocols: IEnumerable_1<CLROf<string>>;
readonly SecWebSocketVersion: string;
readonly User: IPrincipal;
readonly WebSocket: WebSocket;
}
export const HttpListenerWebSocketContext: {
new(): HttpListenerWebSocketContext$instance;
};
export type HttpListenerWebSocketContext = HttpListenerWebSocketContext$instance;
export interface WebSocket$instance {
readonly CloseStatus: Nullable_1<WebSocketCloseStatus>;
readonly CloseStatusDescription: string;
readonly State: WebSocketState;
readonly SubProtocol: string;
Abort(): void;
CloseAsync(closeStatus: WebSocketCloseStatus, statusDescription: string, cancellationToken: CancellationToken): Task;
CloseOutputAsync(closeStatus: WebSocketCloseStatus, statusDescription: string, cancellationToken: CancellationToken): Task;
Dispose(): void;
ReceiveAsync(buffer: ArraySegment_1<CLROf<byte>>, cancellationToken: CancellationToken): Task_1<WebSocketReceiveResult>;
ReceiveAsync(buffer: Memory_1<CLROf<byte>>, cancellationToken: CancellationToken): ValueTask_1<ValueWebSocketReceiveResult>;
SendAsync(buffer: ArraySegment_1<CLROf<byte>>, messageType: WebSocketMessageType, endOfMessage: boolean, cancellationToken: CancellationToken): Task;
SendAsync(buffer: ReadOnlyMemory_1<CLROf<byte>>, messageType: WebSocketMessageType, endOfMessage: boolean, cancellationToken: CancellationToken): ValueTask;
SendAsync(buffer: ReadOnlyMemory_1<CLROf<byte>>, messageType: WebSocketMessageType, messageFlags: WebSocketMessageFlags, cancellationToken?: CancellationToken): ValueTask;
}
export const WebSocket: {
readonly DefaultKeepAliveInterval: TimeSpan;
CreateClientBuffer(receiveBufferSize: int, sendBufferSize: int): ArraySegment_1<CLROf<byte>>;
CreateClientWebSocket(innerStream: Stream, subProtocol: string, receiveBufferSize: int, sendBufferSize: int, keepAliveInterval: TimeSpan, useZeroMaskingKey: boolean, internalBuffer: ArraySegment_1<CLROf<byte>>): WebSocket;
CreateFromStream(stream: Stream, isServer: boolean, subProtocol: string, keepAliveInterval: TimeSpan): WebSocket;
CreateFromStream(stream: Stream, options: WebSocketCreationOptions): WebSocket;
CreateServerBuffer(receiveBufferSize: int): ArraySegment_1<CLROf<byte>>;
IsApplicationTargeting45(): boolean;
RegisterPrefixes(): void;
};
export interface __WebSocket$views {
As_IDisposable(): System_Internal.IDisposable$instance;
}
export interface WebSocket$instance extends System_Internal.IDisposable$instance {}
export type WebSocket = WebSocket$instance & __WebSocket$views;
export interface WebSocketContext$instance {
readonly CookieCollection: CookieCollection;
readonly Headers: NameValueCollection;
readonly IsAuthenticated: boolean;
readonly IsLocal: boolean;
readonly IsSecureConnection: boolean;
readonly Origin: string;
readonly RequestUri: Uri;
readonly SecWebSocketKey: string;
readonly SecWebSocketProtocols: IEnumerable_1<CLROf<string>>;
readonly SecWebSocketVersion: string;
readonly User: IPrincipal;
readonly WebSocket: WebSocket;
}
export const WebSocketContext: {
};
export type WebSocketContext = WebSocketContext$instance;
export interface WebSocketCreationOptions$instance {
DangerousDeflateOptions: WebSocketDeflateOptions;
IsServer: boolean;
KeepAliveInterval: TimeSpan;
KeepAliveTimeout: TimeSpan;
SubProtocol: string;
}
export const WebSocketCreationOptions: {
new(): WebSocketCreationOptions$instance;
};
export type WebSocketCreationOptions = WebSocketCreationOptions$instance;
export interface WebSocketDeflateOptions$instance {
ClientContextTakeover: boolean;
ClientMaxWindowBits: int;
ServerContextTakeover: boolean;
ServerMaxWindowBits: int;
}
export const WebSocketDeflateOptions: {
new(): WebSocketDeflateOptions$instance;
};
export type WebSocketDeflateOptions = WebSocketDeflateOptions$instance;
export interface WebSocketException$instance extends Win32Exception {
readonly ErrorCode: int;
readonly WebSocketErrorCode: WebSocketError;
GetObjectData(info: SerializationInfo, context: StreamingContext): void;
}
export const WebSocketException: {
new(): WebSocketException$instance;
new(error: WebSocketError): WebSocketException$instance;
new(error: WebSocketError, message: string): WebSocketException$instance;
new(error: WebSocketError, innerException: Exception): WebSocketException$instance;
new(error: WebSocketError, message: string, innerException: Exception): WebSocketException$instance;
new(nativeError: int): WebSocketException$instance;
new(nativeError: int, message: string): WebSocketException$instance;
new(nativeError: int, innerException: Exception): WebSocketException$instance;
new(error: WebSocketError, nativeError: int): WebSocketException$instance;
new(error: WebSocketError, nativeError: int, message: string): WebSocketException$instance;
new(error: WebSocketError, nativeError: int, innerException: Exception): WebSocketException$instance;
new(error: WebSocketError, nativeError: int, message: string, innerException: Exception): WebSocketException$instance;
new(message: string): WebSocketException$instance;
new(message: string, innerException: Exception): WebSocketException$instance;
};
export interface __WebSocketException$views {
As_ISerializable(): System_Runtime_Serialization_Internal.ISerializable$instance;
}
export type WebSocketException = WebSocketException$instance & __WebSocketException$views;
export interface WebSocketReceiveResult$instance {
readonly CloseStatus: Nullable_1<WebSocketCloseStatus>;
readonly CloseStatusDescription: string;
readonly Count: int;
readonly EndOfMessage: boolean;
readonly MessageType: WebSocketMessageType;
}
export const WebSocketReceiveResult: {
new(count: int, messageType: WebSocketMessageType, endOfMessage: boolean): WebSocketReceiveResult$instance;
new(count: int, messageType: WebSocketMessageType, endOfMessage: boolean, closeStatus: Nullable_1<WebSocketCloseStatus>, closeStatusDescription: string): WebSocketReceiveResult$instance;
};
export type WebSocketReceiveResult = WebSocketReceiveResult$instance;
export interface WebSocketStream$instance extends Stream {
readonly CanRead: boolean;
readonly CanSeek: boolean;
readonly CanWrite: boolean;
readonly Length: long;
Position: long;
readonly WebSocket: WebSocket;
BeginRead(buffer: byte[], offset: int, count: int, callback: AsyncCallback, state: unknown): IAsyncResult;
BeginWrite(buffer: byte[], offset: int, count: int, callback: AsyncCallback, state: unknown): IAsyncResult;
Dispose(): void;
DisposeAsync(): ValueTask;
EndRead(asyncResult: IAsyncResult): int;
EndWrite(asyncResult: IAsyncResult): void;
Flush(): void;
FlushAsync(cancellationToken: CancellationToken): Task;
FlushAsync(): Task;
Read(buffer: byte[], offset: int, count: int): int;
Read(buffer: Span_1<CLROf<byte>>): int;
ReadAsync(buffer: byte[], offset: int, count: int, cancellationToken: CancellationToken): Task_1<CLROf<int>>;
ReadAsync(buffer: Memory_1<CLROf<byte>>, cancellationToken?: CancellationToken): ValueTask_1<CLROf<int>>;
ReadAsync(buffer: byte[], offset: int, count: int): Task_1<CLROf<int>>;
ReadAsync(buffer: byte[], offset: int, count: int, cancellationToken: CancellationToken): Task_1<CLROf<int>>;
ReadAsync(buffer: Memory_1<CLROf<byte>>, cancellationToken?: CancellationToken): ValueTask_1<CLROf<int>>;
Seek(offset: long, origin: SeekOrigin): long;
SetLength(value: long): void;
Write(buffer: byte[], offset: int, count: int): void;
Write(buffer: ReadOnlySpan_1<CLROf<byte>>): void;
WriteAsync(buffer: byte[], offset: int, count: int, cancellationToken: CancellationToken): Task;
WriteAsync(buffer: ReadOnlyMemory_1<CLROf<byte>>, cancellationToken?: CancellationToken): ValueTask;
WriteAsync(buffer: byte[], offset: int, count: int): Task;
WriteAsync(buffer: ReadOnlyMemory_1<CLROf<byte>>, cancellationToken?: CancellationToken): ValueTask;
}
export const WebSocketStream: {
new(): WebSocketStream$instance;
Create(webSocket: WebSocket, writeMessageType: WebSocketMessageType, ownsWebSocket?: boolean): WebSocketStream;
Create(webSocket: WebSocket, writeMessageType: WebSocketMessageType, closeTimeout: TimeSpan): WebSocketStream;
CreateReadableMessageStream(webSocket: WebSocket): WebSocketStream;
CreateWritableMessageStream(webSocket: WebSocket, writeMessageType: WebSocketMessageType): WebSocketStream;
};
export interface __WebSocketStream$views {
As_IAsyncDisposable(): System_Internal.IAsyncDisposable$instance;
As_IDisposable(): System_Internal.IDisposable$instance;
}
export type WebSocketStream = WebSocketStream$instance & __WebSocketStream$views;