aboutsummaryrefslogtreecommitdiff
path: root/Tools/Hazel-Networking/Hazel.UnitTests/Dtls/TestDtlsHandshakeDropUnityConnection.cs
blob: f33cd143357763b2f50dcdef0c437a3f7c5ac29b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
using Hazel.Dtls;
using System.Net;

namespace Hazel.UnitTests.Dtls
{
    internal class TestDtlsHandshakeDropUnityConnection : DtlsUnityConnection
    {
        public int DropSendClientKeyExchangeFlightCount = 0;

        public TestDtlsHandshakeDropUnityConnection(ILogger logger, IPEndPoint remoteEndPoint, IPMode ipMode = IPMode.IPv4) : base(logger, remoteEndPoint, ipMode)
        {

        }

        protected override bool DropClientKeyExchangeFlight()
        {
            if (DropSendClientKeyExchangeFlightCount > 0)
            {
                this.logger.WriteInfo($"Dropping SendClientKeyExchangeFlight");
                --DropSendClientKeyExchangeFlightCount;
                return true;
            }

            return false;
        }
    }
}