Перейти к основному содержимому
Версия: 5.x

DarkWS.Testing.DarkWsTestConnection

DarkWS.Testing​

DarkWS.Testing​

DarkWsTestConnection Class​

A transportless connection that captures copies of sent response and broadcast bytes.

public sealed class DarkWsTestConnection : DarkWS.Abstractions.IWebSocketConnection, System.IDisposable

Inheritance System.Object → DarkWsTestConnection

Implements DarkWS.Abstractions.IWebSocketConnection, System.IDisposable

Constructors​

DarkWsTestConnection(IDarkWsSession, HttpContext) Constructor​

Creates a connection with a fixed session and optional HTTP context. The session determines the HTTP user.

public DarkWsTestConnection(DarkWS.Abstractions.IDarkWsSession? session=null, Microsoft.AspNetCore.Http.HttpContext? httpContext=null);

Parameters​

session DarkWS.Abstractions.IDarkWsSession

httpContext Microsoft.AspNetCore.Http.HttpContext

Properties​

DarkWsTestConnection.HttpContext Property​

Gets the supplied or default HTTP context.

public Microsoft.AspNetCore.Http.HttpContext HttpContext { get; }

Implements HttpContext

Property Value​

Microsoft.AspNetCore.Http.HttpContext

DarkWsTestConnection.Id Property​

Gets the generated connection id used for targeted broadcasts.

public string Id { get; }

Implements Id

Property Value​

System.String

DarkWsTestConnection.IsOpen Property​

Gets whether the connection accepts sends.

public bool IsOpen { get; }

Implements IsOpen

Property Value​

System.Boolean

DarkWsTestConnection.SentMessages Property​

Gets a snapshot of captured UTF-8 messages, in send order.

public System.Collections.Generic.IReadOnlyList<byte[]> SentMessages { get; }

Property Value​

System.Collections.Generic.IReadOnlyList<System.Byte[]>

DarkWsTestConnection.Session Property​

Gets the session supplied when this connection was created.

public DarkWS.Abstractions.IDarkWsSession? Session { get; }

Implements Session

Property Value​

DarkWS.Abstractions.IDarkWsSession

Methods​

DarkWsTestConnection.Abort() Method​

Immediately stops accepting sends.

public void Abort();

Implements Abort()

DarkWsTestConnection.CloseAsync(CancellationToken) Method​

Closes the connection without a transport handshake.

public System.Threading.Tasks.Task CloseAsync(System.Threading.CancellationToken cancellationToken=default(System.Threading.CancellationToken));

Parameters​

cancellationToken System.Threading.CancellationToken

Implements CloseAsync(CancellationToken)

Returns​

System.Threading.Tasks.Task

DarkWsTestConnection.Dispose() Method​

Stops accepting sends; captured messages remain available.

public void Dispose();

Implements Dispose()

DarkWsTestConnection.SendAsync(ReadOnlyMemory<byte>, CancellationToken) Method​

Captures a copy of the data. Closed connections ignore sends, like the server transport.

public System.Threading.Tasks.Task SendAsync(System.ReadOnlyMemory<byte> data, System.Threading.CancellationToken cancellationToken=default(System.Threading.CancellationToken));

Parameters​

data System.ReadOnlyMemory<System.Byte>

cancellationToken System.Threading.CancellationToken

Implements SendAsync(ReadOnlyMemory<byte>, CancellationToken)

Returns​

System.Threading.Tasks.Task