/// <summary> /// Constructor /// </summary> /// <param name="context"></param> public Rdpbcgr_DVCClientTransport(RdpbcgrClientContext context) { this.context = context; if (context.SVCManager == null) { throw new NotSupportedException("Cannot get SVC from RDPBCGR connection for RDPEDYC, this transport must be created after RDPBCGR connection established."); } channel = context.SVCManager.GetChannelByName(StaticVirtualChannelName.RDPEDYC); if (channel == null) { throw new NotSupportedException("Cannot get SVC from RDPBCGR connection for RDPEDYC, the static virtual channel is not created."); } channel.Received += ReceivedBytes; if (!context.SVCManager.IsRunning) { // Must start the SVC manager here, so as to make sure the first packet of RDPEDYC can be processed context.SVCManager.Start(); } decoder = new ClientDecodingPduBuilder(); pduBuilder = new PduBuilder(); }
/// <summary> /// Constructor /// </summary> /// <param name="context"></param> public Rdpbcgr_DVCServerTransport(RdpbcgrServerSessionContext context) { this.sessionContext = context; if (sessionContext.SVCManager == null) { throw new NotSupportedException("Cannot get SVC from RDPBCGR connection for RDPEDYC, this transport must be created after RDPBCGR connection established."); } channel = sessionContext.SVCManager.GetChannelByName(StaticVirtualChannelName.RDPEDYC); if (channel == null) { throw new NotSupportedException("Cannot get SVC from RDPBCGR connection for RDPEDYC, the static virtual channel is not created."); } channel.Received += ReceivedBytes; if (!sessionContext.SVCManager.IsRunning) { // Better start the SVC manager here, so as to make sure the first packet of RDPEDYC can be processed // it is not same restrict as client, since the first packet is sent by server sessionContext.SVCManager.Start(); } decoder = new ServerDecodingPduBuilder(); pduBuilder = new PduBuilder(); }
/// <summary> /// Generate static virtual channel traffics /// </summary> /// <param name="invalidType">Invalid Type used for negative test case</param> public void GenerateStaticVirtualChannelTraffics(NegativeType invalidType) { if (rdpbcgrClientStack.Context.SVCManager == null) { Site.Assume.Fail("SVC Manager must be created before generate static virtual channel data."); } StaticVirtualChannel RDPEDYCChannel = rdpbcgrClientStack.Context.SVCManager.GetChannelByName(SVCNameForRDPEDYC); if (RDPEDYCChannel == null) { Site.Assume.Fail("Static virtual channel: {0} must be created.", SVCNameForRDPEDYC); } ushort channelId = RDPEDYCChannel.ChannelId; // Expect a RDPEDYC caps request PDU Virtual_Channel_RAW_Server_Pdu svcPdu = this.ExpectPacket <Virtual_Channel_RAW_Server_Pdu>(pduWaitTimeSpan); if (svcPdu == null) { Site.Assert.Fail("Timeout when receiving RDPEDYC static virtual channel data."); } ClientDecodingPduBuilder decoder = new ClientDecodingPduBuilder(); PduBuilder pduBuilder = new PduBuilder(); DynamicVCPDU pdu = decoder.ToPdu(svcPdu.virtualChannelData); if (pdu == null) { Site.Assert.Fail("Received static virtual channel data must be a DVC Capabilities Request PDU!"); } DYNVC_CAPS_Version version = DYNVC_CAPS_Version.VERSION3; if (pdu is CapsVer1ReqDvcPdu) { version = DYNVC_CAPS_Version.VERSION1; } else if (pdu is CapsVer2ReqDvcPdu) { version = DYNVC_CAPS_Version.VERSION2; } // Response a RDPEDYC caps response PDU CapsRespDvcPdu capResp = pduBuilder.CreateCapsRespPdu((ushort)version); SendVirtualChannelPDU(channelId, pduBuilder.ToRawData(capResp), invalidType); }