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

net-daemon / netdaemon / 29151876811

11 Jul 2026 11:59AM UTC coverage: 84.938% (+1.3%) from 83.603%
29151876811

Pull #1385

github

web-flow
Merge 0500e18ce into ca717d7ab
Pull Request #1385: MQTT Upgrade - attempt 2

973 of 1289 branches covered (75.48%)

Branch coverage included in aggregate %.

220 of 248 new or added lines in 5 files covered. (88.71%)

9 existing lines in 3 files now uncovered.

3651 of 4155 relevant lines covered (87.87%)

2298.09 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,781✔
27

28
    public WebSocketCloseStatus? CloseStatus => _ws.CloseStatus;
1,263✔
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);
1,015✔
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