Microsoft.Protocols.TestTools.StackSdk.RemoteDesktop.Rdpeudp.RdpeudpSocket.ExpectPacket C# (CSharp) Method

ExpectPacket() public method

public ExpectPacket ( System.TimeSpan timeout ) : RdpeudpPacket
timeout System.TimeSpan
return RdpeudpPacket
        public RdpeudpPacket ExpectPacket(TimeSpan timeout)
        {
            DateTime endtime = DateTime.Now + timeout;
            while (DateTime.Now < endtime)
            {
                lock (unProcessedPacketBuffer)
                {
                    if (unProcessedPacketBuffer.Count > 0)
                    {
                        RdpeudpPacket eudpPacket = unProcessedPacketBuffer[0];
                        unProcessedPacketBuffer.RemoveAt(0);
                        return eudpPacket;
                    }
                }
                // If not receive a Packet, wait a while
                Thread.Sleep(RdpeudpSocketConfig.ReceivingInterval);
            }
            return null;
        }

Usage Example

        /// <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);
                }
            }
        }
All Usage Examples Of Microsoft.Protocols.TestTools.StackSdk.RemoteDesktop.Rdpeudp.RdpeudpSocket::ExpectPacket