示例#1
0
        /// <summary>
        /// <see cref="IDisposable.Dispose"/>
        /// </summary>
        public void Dispose()
        {
            if (this.dtls != null)
            {
                this.dtls.Dispose();
                this.dtls = null;
            }

            if (this.udp != null)
            {
                this.udp.Dispose();
                this.udp = null;
            }
        }
示例#2
0
        /// <summary>
        /// <see cref="IDisposable.Dispose"/>
        /// </summary>
        public void Dispose()
        {
            if (!(this.dtls is null))
            {
                this.dtls.Dispose();
                this.dtls = null;
            }

            if (!(this.udp is null))
            {
                this.udp.Dispose();
                this.udp = null;
            }
        }
示例#3
0
        /// <summary>
        /// Class managing DTLS over UDP.
        /// </summary>
        /// <param name="UdpClient">UDP connection.</param>
        /// <param name="Mode">DTLS mode.</param>
        /// <param name="Users">User data source, if pre-shared keys should be allowed by a DTLS server endpoint.</param>
        /// <param name="RequiredPrivilege">Required privilege, for the user to be acceptable
        /// in PSK handshakes.</param>
        /// <param name="Sniffers">Sniffers.</param>
        public DtlsOverUdp(UdpClient UdpClient, DtlsMode Mode, IUserSource Users,
                           string RequiredPrivilege, params ISniffer[] Sniffers)
        {
            this.udp  = new UdpCommunicationLayer(UdpClient);
            this.dtls = new DtlsEndpoint(Mode, this.udp, Users, RequiredPrivilege, Sniffers);

            this.dtlsStates                       = new Cache <IPEndPoint, DtlsOverUdpState>(int.MaxValue, TimeSpan.MaxValue, new TimeSpan(1, 0, 0));
            this.dtlsStates.Removed              += DtlsStates_Removed;
            this.dtls.OnApplicationDataReceived  += Dtls_OnApplicationDataReceived;
            this.dtls.OnHandshakeFailed          += Dtls_OnHandshakeFailed;
            this.dtls.OnHandshakeSuccessful      += Dtls_OnHandshakeSuccessful;
            this.dtls.OnSessionFailed            += Dtls_OnSessionFailed;
            this.dtls.OnIncomingHandshakeStarted += Dtls_OnIncomingHandshakeStarted;
            this.dtls.OnStateChanged             += Dtls_OnStateChanged;
        }