/// <summary> /// Constructor /// </summary> /// <param name="eudpSocket">RDPEUDP Socket, which is transport</param> public RdpeudpDTLSChannel(RdpeudpSocket eudpSocket) { if (eudpSocket == null || eudpSocket.TransMode == TransportMode.Reliable) { throw new NotSupportedException("RdpeudpSocket is null or it is a socket for reliable RDPEUDP connection."); } this.rdpeudpSocket = eudpSocket; this.rdpeudpSocket.Received += ReceiveBytes; isAuthenticated = false; rdpeudpSocket.Disconnected += RdpeudpSocket_Disconnected; receivedBuffer = new List <byte[]>(); toSendBuffer = new List <byte[]>(); if (eudpSocket.AutoHandle) { // Check whether there is packets in unprocessed packet buffer RdpeudpPacket packet = eudpSocket.ExpectPacket(shortWaitTime); if (packet != null) { eudpSocket.ReceivePacket(packet); } } }
/// <summary> /// Expect for a Source Packet. /// </summary> /// <param name="udpTransportMode">Transport mode: reliable or lossy.</param> /// <param name="timeout">Wait time</param> /// <returns></returns> private RdpeudpPacket WaitForSourcePacket(TransportMode udpTransportMode, TimeSpan timeout, uint sequnceNumber = 0) { RdpeudpSocket rdpeudpSocket = rdpeudpSocketR; if (udpTransportMode == TransportMode.Lossy) { rdpeudpSocket = rdpeudpSocketL; } DateTime endTime = DateTime.Now + timeout; while (DateTime.Now < endTime) { RdpeudpPacket packet = rdpeudpSocket.ExpectPacket(endTime - DateTime.Now); if (packet != null && packet.fecHeader.uFlags.HasFlag(RDPUDP_FLAG.RDPUDP_FLAG_DATA)) { if (sequnceNumber == 0 || packet.sourceHeader.Value.snSourceStart == sequnceNumber) { return(packet); } } } return(null); }
/// <summary> /// Constructor /// </summary> /// <param name="eudpSocket">A RdpeudpSocket used for transport</param> public RdpeudpTLSChannel(RdpeudpSocket eudpSocket) { if (eudpSocket == null || eudpSocket.TransMode == TransportMode.Lossy) { throw new NotSupportedException("RdpeudpSocket is null or it is a socket for Lossy RDPEUDP connection."); } this.rdpeudpSocket = eudpSocket; this.rdpeudpSocket.Received += ReceiveBytes; innerStream = new SSLInnerStream(); isAuthenticated = false; if (eudpSocket.AutoHandle) { // Check whether there is packets in unprocessed packet buffer RdpeudpPacket packet = eudpSocket.ExpectPacket(shortWaitTime); if (packet != null) { eudpSocket.ReceivePacket(packet); } } }