• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

net-daemon / netdaemon / 9343360009

26 May 2024 02:03PM UTC coverage: 82.867% (-0.1%) from 82.999%
9343360009

push

github

web-flow
Housecleaning  (#1108)

* Housecleaning - step 1

* More small fixes

863 of 1189 branches covered (72.58%)

Branch coverage included in aggregate %.

29 of 34 new or added lines in 23 files covered. (85.29%)

6 existing lines in 2 files now uncovered.

3224 of 3743 relevant lines covered (86.13%)

81.64 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

70.0
/src/Client/NetDaemon.HassClient/Internal/Net/WebSocketClientImpl.cs
1
namespace NetDaemon.Client.Internal.Net;
2

3
/// <summary>
4
///     This class wraps the ClientWebSocket so we can do
5
///     mockable communications
6
/// </summary>
7
internal class WebSocketClientImpl : IWebSocketClient
8
{
9
    private readonly ClientWebSocket _ws;
10

11
    /// <summary>
12
    ///     Constructor
13
    /// </summary>
14
    /// <param name="bypassCertificateErrors">
15
    ///     Provide the hash string for certificate that the websocket should ignore
16
    ///     errors from
17
    /// </param>
18
    public WebSocketClientImpl(bool bypassCertificateErrors = false)
32✔
19
    {
20
        _ws = new ClientWebSocket();
32✔
21

22
        if (bypassCertificateErrors)
32!
NEW
23
            _ws.Options.RemoteCertificateValidationCallback = (_, _, _, sslPolicyErrors) => sslPolicyErrors == SslPolicyErrors.None || true;
×
24
    }
32✔
25

26
    public WebSocketState State => _ws.State;
1,054✔
27

28
    public WebSocketCloseStatus? CloseStatus => _ws.CloseStatus;
592✔
29

30
    public Task ConnectAsync(Uri uri, CancellationToken cancel)
31
    {
32
        return _ws.ConnectAsync(uri, cancel);
31✔
33
    }
34

35
    public Task CloseAsync(WebSocketCloseStatus closeStatus, string statusDescription,
36
        CancellationToken cancellationToken)
37
    {
38
        return _ws.CloseAsync(closeStatus, statusDescription, cancellationToken);
22✔
39
    }
40

41
    public Task CloseOutputAsync(WebSocketCloseStatus closeStatus, string statusDescription,
42
        CancellationToken cancellationToken)
43
    {
44
        return _ws.CloseAsync(closeStatus, statusDescription, cancellationToken);
8✔
45
    }
46

47
    public Task SendAsync(ArraySegment<byte> buffer, WebSocketMessageType messageType, bool endOfMessage,
48
        CancellationToken cancellationToken)
49
    {
50
        return _ws.SendAsync(buffer, messageType, endOfMessage, cancellationToken);
213✔
51
    }
52

53
    public async ValueTask SendAsync(ReadOnlyMemory<byte> buffer, WebSocketMessageType messageType,
54
        bool endOfMessage, CancellationToken cancellationToken)
55
    {
56
        await Task.FromException(new NotImplementedException()).ConfigureAwait(false);
×
57
    }
×
58

59
    public ValueTask<ValueWebSocketReceiveResult> ReceiveAsync(Memory<byte> buffer,
60
        CancellationToken cancellationToken)
61
    {
62
        return _ws.ReceiveAsync(buffer, cancellationToken);
377✔
63
    }
64

65
    public ValueTask DisposeAsync()
66
    {
67
        _ws.Dispose();
29✔
68
        return ValueTask.CompletedTask;
29✔
69
    }
70
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc