Skip to content

Add WebSocketStream #116729

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ public async Task<Connection> EstablishConnectionAsync()
Stream stream = null;
#if TARGET_BROWSER
closableWrapper = new SocketWrapper(_listenSocket);
stream = new WebSocketStream(_listenSocket, ownsSocket: true);
stream = WebSocketStream.Create(_listenSocket, WebSocketMessageType.Binary, ownsWebSocket: true);
#else
var socket = await _listenSocket.AcceptAsync().ConfigureAwait(false);
closableWrapper = new SocketWrapper(socket);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,5 @@
GlobalPropertiesToRemove="TargetOS;TargetArchitecture;RuntimeIdentifier;RunAOTCompilation"
AdditionalProperties="_TargetFrameworkForXHarness=$(_TargetFrameworkForXHarness)"
ReferenceOutputAssembly="false"/>
<Compile Include="$(CommonTestPath)System\Net\WebSockets\WebSocketStream.cs"
Link="Common\System\Net\WebSockets\WebSocketStream.cs" />
</ItemGroup>
</Project>
277 changes: 0 additions & 277 deletions src/libraries/Common/tests/System/Net/WebSockets/WebSocketStream.cs

This file was deleted.

30 changes: 30 additions & 0 deletions src/libraries/System.Net.WebSockets/ref/System.Net.WebSockets.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,36 @@ public static void RegisterPrefixes() { }
public virtual System.Threading.Tasks.ValueTask SendAsync(System.ReadOnlyMemory<byte> buffer, System.Net.WebSockets.WebSocketMessageType messageType, System.Net.WebSockets.WebSocketMessageFlags messageFlags, System.Threading.CancellationToken cancellationToken) { throw null; }
protected static void ThrowOnInvalidState(System.Net.WebSockets.WebSocketState state, params System.Net.WebSockets.WebSocketState[] validStates) { }
}
public partial class WebSocketStream : System.IO.Stream
{
private protected WebSocketStream() { }
public override System.IAsyncResult BeginWrite(byte[] buffer, int offset, int count, System.AsyncCallback? callback, object? state) { throw null; }
public override System.IAsyncResult BeginRead(byte[] buffer, int offset, int count, System.AsyncCallback? callback, object? state) { throw null; }
public override bool CanRead { get { throw null; } }
public override bool CanSeek { get { throw null; } }
public override bool CanWrite { get { throw null; } }
public static System.Net.WebSockets.WebSocketStream Create(WebSocket webSocket, WebSocketMessageType writeMessageType, bool ownsWebSocket = false) { throw null; }
public static System.Net.WebSockets.WebSocketStream Create(WebSocket webSocket, WebSocketMessageType writeMessageType, TimeSpan closeTimeout) { throw null; }
public static System.Net.WebSockets.WebSocketStream CreateWritableMessageStream(WebSocket webSocket, WebSocketMessageType writeMessageType) { throw null; }
public static System.Net.WebSockets.WebSocketStream CreateReadableMessageStream(WebSocket webSocket) { throw null; }
protected override void Dispose(bool disposing) { }
public override System.Threading.Tasks.ValueTask DisposeAsync() { throw null; }
public override int EndRead(System.IAsyncResult asyncResult) { throw null; }
public override void EndWrite(IAsyncResult asyncResult) { }
public override void Flush() { }
public override System.Threading.Tasks.Task FlushAsync(System.Threading.CancellationToken cancellationToken) { throw null; }
public override long Length { get { throw null; } }
public override long Position { get { throw null; } set { } }
public override int Read(byte[] buffer, int offset, int count) { throw null; }
public override System.Threading.Tasks.Task<int> ReadAsync(byte[] buffer, int offset, int count, System.Threading.CancellationToken cancellationToken) { throw null; }
public override System.Threading.Tasks.ValueTask<int> ReadAsync(System.Memory<byte> buffer, System.Threading.CancellationToken cancellationToken = default) { throw null; }
public override long Seek(long offset, System.IO.SeekOrigin origin) { throw null; }
public override void SetLength(long value) { }
public System.Net.WebSockets.WebSocket WebSocket { get { throw null; } }
public override void Write(byte[] buffer, int offset, int count) { throw null; }
public override System.Threading.Tasks.Task WriteAsync(byte[] buffer, int offset, int count, System.Threading.CancellationToken cancellationToken) { throw null; }
public override System.Threading.Tasks.ValueTask WriteAsync(System.ReadOnlyMemory<byte> buffer, System.Threading.CancellationToken cancellationToken = default) { throw null; }
}
public enum WebSocketCloseStatus
{
NormalClosure = 1000,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,9 @@
<data name="net_WebSockets_ArgumentOutOfRange" xml:space="preserve">
<value>The argument must be a value between {0} and {1}.</value>
</data>
<data name="net_WebSockets_TimeoutOutOfRange" xml:space="preserve">
<value>The timeout must be a value between non-negative or Timeout.InfiniteTimeSpan.</value>
</data>
<data name="net_Websockets_KeepAlivePingTimeout" xml:space="preserve">
<value>The WebSocket didn't recieve a Pong frame in response to a Ping frame within the configured KeepAliveTimeout.</value>
</data>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
<Compile Include="System\Net\WebSockets\WebSocketReceiveResult.cs" />
<Compile Include="System\Net\WebSockets\WebSocketState.cs" />
<Compile Include="System\Net\WebSockets\WebSocketStateHelper.cs" />
<Compile Include="System\Net\WebSockets\WebSocketStream.cs" />
<Compile Include="$(CommonPath)System\Net\WebSockets\WebSocketDefaults.cs"
Link="Common\System\Net\WebSockets\WebSocketDefaults.cs" />
<Compile Include="$(CommonPath)System\Net\WebSockets\WebSocketValidate.cs"
Expand Down
Loading
Loading