/// <summary> /// Expect a DVC Capabilities Response PDU /// </summary> /// <param name="timeout">Timeout</param> /// <param name="transportType">Transport type</param> /// <returns></returns> private CapsRespDvcPdu ExpectDVCCapResponsePDU(TimeSpan timeout, DynamicVC_TransportType transportType = DynamicVC_TransportType.RDP_TCP) { DateTime endTime = DateTime.Now + timeout; while (DateTime.Now < endTime) { if (unprocessedDVCPacketBuffer.Count > 0) { lock (unprocessedDVCPacketBuffer) { for (int i = 0; i < unprocessedDVCPacketBuffer.Count; i++) { if (transportType == unprocessedDVCPacketBuffer[i].TransportType && unprocessedDVCPacketBuffer[i].PDU is CapsRespDvcPdu) { CapsRespDvcPdu capResp = unprocessedDVCPacketBuffer[i].PDU as CapsRespDvcPdu; unprocessedDVCPacketBuffer.RemoveAt(i); return(capResp); } } } } Thread.Sleep(this.waitInterval); } return(null); }
/// <summary> /// Exchange DVC capability, negotiate the version /// </summary> /// <param name="version"></param> public void ExchangeCapabilities(TimeSpan timeout, DYNVC_CAPS_Version version = DYNVC_CAPS_Version.VERSION3) { this.SendDVCCapRequestPDU(version); CapsRespDvcPdu capResp = this.ExpectDVCCapResponsePDU(timeout); if (capResp == null) { throw new System.IO.IOException("Cannot receive a DVC Capabilities Response PDU!"); } }
/// <summary> /// Send a DVC Capabilities Response PDU /// </summary> /// <param name="version">Version</param> /// <param name="transportType">Transport Type</param> private void SendDVCCapResponsePDU(DYNVC_CAPS_Version version, DynamicVC_TransportType transportType = DynamicVC_TransportType.RDP_TCP) { CapsRespDvcPdu capResp = pduBuilder.CreateCapsRespPdu((ushort)version); this.Send(capResp, transportType); }