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

net-daemon / netdaemon / 26664505682

29 May 2026 10:02PM UTC coverage: 84.665% (+0.7%) from 83.944%
26664505682

Pull #1385

github

web-flow
Merge 75524c276 into 0116c9815
Pull Request #1385: MQTT Upgrade - attempt 2

907 of 1217 branches covered (74.53%)

Branch coverage included in aggregate %.

113 of 135 new or added lines in 5 files covered. (83.7%)

2 existing lines in 2 files now uncovered.

3521 of 4013 relevant lines covered (87.74%)

1288.9 hits per line

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

65.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)
35✔
19
    {
20
        _ws = new ClientWebSocket();
35✔
21

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

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

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

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

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

41
    public Task CloseOutputAsync(WebSocketCloseStatus closeStatus, string statusDescription,
42
        CancellationToken cancellationToken)
43
    {
UNCOV
44
        return _ws.CloseAsync(closeStatus, statusDescription, cancellationToken);
×
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);
230✔
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);
433✔
63
    }
64

65
    public ValueTask DisposeAsync()
66
    {
67
        _ws.Dispose();
32✔
68
        return ValueTask.CompletedTask;
32✔
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