/// <summary> /// Expect a DYNVC_SOFT_SYNC_RESPONSE PDU. /// </summary> private SoftSyncResDvcPdu ExpectSoftSyncResponsePDU(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 SoftSyncResDvcPdu) { SoftSyncResDvcPdu capResp = unprocessedDVCPacketBuffer[i].PDU as SoftSyncResDvcPdu; unprocessedDVCPacketBuffer.RemoveAt(i); return(capResp); } } } } Thread.Sleep(this.waitInterval); } return(null); }
/// <summary> /// Send Soft Sync request and wait for Soft Sync response. /// </summary> /// <param name="timeout">wait time</param> /// <param name="flags">specifies the contents of this PDU</param> /// <param name="numberOfTunnels">tunnel numbers</param> /// <param name="channelList">DYNVC_SOFT_SYNC_CHANNEL_LISTs</param> public void SoftSyncNegotiate(TimeSpan timeout, SoftSyncReqFlags_Value flags, ushort numberOfTunnels, SoftSyncChannelList[] channelList = null) { this.SendSoftSyncRequestPDU(flags, numberOfTunnels, channelList); SoftSyncResDvcPdu pdu = this.ExpectSoftSyncResponsePDU(timeout); if (pdu == null) { throw new System.IO.IOException("Cannot receive a Soft Sync Response PDU!"); } }