Пример #1
0
 /// <summary>
 /// The callback method to receive data from transport layer.
 /// </summary>
 private void OnDataReceived(byte[] data, uint channelID)
 {
     lock (receivedList)
     {
         RdpedispPdu basePDU  = new RdpedispPdu();
         bool        fSucceed = false;
         bool        fResult  = PduMarshaler.Unmarshal(data, basePDU);
         if (fResult)
         {
             byte[] pduData = new byte[basePDU.Header.Length];
             Array.Copy(data, pduData, basePDU.Header.Length);
             if (basePDU.Header.Type == PDUTypeValues.DISPLAYCONTROL_PDU_TYPE_CAPS)
             {
                 DISPLAYCONTROL_CAPS_PDU capsPDU = new DISPLAYCONTROL_CAPS_PDU();
                 try
                 {
                     fSucceed = PduMarshaler.Unmarshal(pduData, capsPDU);
                     receivedList.Add(capsPDU);
                 }
                 catch (PDUDecodeException decodeException)
                 {
                     RdpedispUnkownPdu unkonw = new RdpedispUnkownPdu();
                     fSucceed = PduMarshaler.Unmarshal(decodeException.DecodingData, unkonw);
                     receivedList.Add(unkonw);
                 }
             }
             else if (basePDU.Header.Type == PDUTypeValues.DISPLAYCONTROL_PDU_TYPE_MONITOR_LAYOUT)
             {
                 DISPLAYCONTROL_MONITOR_LAYOUT_PDU monitorLayoutPDU = new DISPLAYCONTROL_MONITOR_LAYOUT_PDU();
                 try
                 {
                     fSucceed = PduMarshaler.Unmarshal(pduData, monitorLayoutPDU);
                     receivedList.Add(monitorLayoutPDU);
                 }
                 catch (PDUDecodeException decodeException)
                 {
                     RdpedispUnkownPdu unkonw = new RdpedispUnkownPdu();
                     fSucceed = PduMarshaler.Unmarshal(decodeException.DecodingData, unkonw);
                     receivedList.Add(unkonw);
                 }
             }
             else
             {
                 RdpedispUnkownPdu unkonw = new RdpedispUnkownPdu();
                 fSucceed = PduMarshaler.Unmarshal(pduData, unkonw);
                 receivedList.Add(unkonw);
             }
         }
         if (!fSucceed || !fResult)
         {
             RdpedispUnkownPdu unkonw = new RdpedispUnkownPdu();
             fSucceed = PduMarshaler.Unmarshal(data, unkonw);
             receivedList.Add(unkonw);
         }
     }
 }
Пример #2
0
        /// <summary>
        /// Method to create DISPLAYCONTROL_CAPS_PDU PDU
        /// </summary>
        /// <param name="maxNumMonitors">A 32-bit unsigned integer that specifies the maximum number of monitors supported by the server</param>
        /// <param name="maxMonitorAreaFactorA">A 32-bit unsigned integer that is used to specify the maximum monitor area supported by the server. </param>
        /// <param name="maxMonitorAreaFactorB">A 32-bit unsigned integer that is used to specify the maximum monitor area supported by the server. </param>
        /// <returns></returns>
        public DISPLAYCONTROL_CAPS_PDU createDisplayControlCapsPdu(
            uint maxNumMonitors,
            uint maxMonitorAreaFactorA,
            uint maxMonitorAreaFactorB)
        {
            DISPLAYCONTROL_CAPS_PDU capsPdu = new DISPLAYCONTROL_CAPS_PDU();

            capsPdu.Header.Type           = PDUTypeValues.DISPLAYCONTROL_PDU_TYPE_CAPS;
            capsPdu.Header.Length         = CapsPduSize;
            capsPdu.MaxNumMonitors        = maxNumMonitors;
            capsPdu.MaxMonitorAreaFactorA = maxMonitorAreaFactorA;
            capsPdu.MaxMonitorAreaFactorB = maxMonitorAreaFactorB;
            return(capsPdu);
        }