示例#1
0
        /// <summary>
        /// Process data coming from the transport. This method analyses the data
        /// and if an object can be created, it creates one and calls the
        /// <paramref name="callback"/> with the deserialized object. This method
        /// does not assume all fragments to be available. So if not enough fragments are
        /// available it will simply return..
        /// </summary>
        /// <param name="data">
        /// Data to process.
        /// </param>
        /// <param name="priorityType">
        /// Priority stream this data belongs to.
        /// </param>
        /// <param name="callback">
        /// Callback to call once a complete deserialized object is available.
        /// </param>
        /// <returns>
        /// Defragmented Object if any, otherwise null.
        /// </returns>
        /// <exception cref="PSRemotingTransportException">
        /// 1. Fragment Ids not in sequence
        /// 2. Object Ids does not match
        /// 3. The current deserialized object size of the received data exceeded
        /// allowed maximum object size. The current deserialized object size is {0}.
        /// Allowed maximum object size is {1}.
        /// 4.The total data received from the remote machine exceeded allowed maximum.
        /// The total data received from remote machine is {0}. Allowed maximum is {1}.
        /// </exception>
        /// <remarks>
        /// Might throw other exceptions as the deserialized object is handled here.
        /// </remarks>
        internal void ProcessRawData(byte[] data,
                                     DataPriorityType priorityType,
                                     ReceiveDataCollection.OnDataAvailableCallback callback)
        {
            Dbg.Assert(data != null, "Cannot process null data");

            try
            {
                _defragmentor.DeserializationContext.LogExtraMemoryUsage(data.Length);
            }
            catch (System.Xml.XmlException)
            {
                PSRemotingTransportException e = null;

                if (_isCreateByClientTM)
                {
                    e = new PSRemotingTransportException(PSRemotingErrorId.ReceivedDataSizeExceededMaximumClient,
                                                         RemotingErrorIdStrings.ReceivedDataSizeExceededMaximumClient,
                                                         _defragmentor.DeserializationContext.MaximumAllowedMemory.Value);
                }
                else
                {
                    e = new PSRemotingTransportException(PSRemotingErrorId.ReceivedDataSizeExceededMaximumServer,
                                                         RemotingErrorIdStrings.ReceivedDataSizeExceededMaximumServer,
                                                         _defragmentor.DeserializationContext.MaximumAllowedMemory.Value);
                }

                throw e;
            }

            _recvdData[(int)priorityType].ProcessRawData(data, callback);
        }
示例#2
0
 protected BaseTransportManager(PSRemotingCryptoHelper cryptoHelper)
 {
     this.cryptoHelper            = cryptoHelper;
     this.fragmentor              = new Fragmentor(32768, cryptoHelper);
     this.recvdData               = new PriorityReceiveDataCollection(this.fragmentor, this is BaseClientTransportManager);
     this.onDataAvailableCallback = new ReceiveDataCollection.OnDataAvailableCallback(this.OnDataAvailableCallback);
 }
 protected BaseClientTransportManager(Guid runspaceId, PSRemotingCryptoHelper cryptoHelper) : base(cryptoHelper)
 {
     this.syncObject = new object();
     this.runspacePoolInstanceId = runspaceId;
     this.dataToBeSent = new PrioritySendDataCollection();
     this.onDataAvailableCallback = new ReceiveDataCollection.OnDataAvailableCallback(this.OnDataAvailableHandler);
     this.callbackNotificationQueue = new Queue<CallbackNotificationInformation>();
 }
 protected BaseClientTransportManager(Guid runspaceId, PSRemotingCryptoHelper cryptoHelper) : base(cryptoHelper)
 {
     this.syncObject                = new object();
     this.runspacePoolInstanceId    = runspaceId;
     this.dataToBeSent              = new PrioritySendDataCollection();
     this.onDataAvailableCallback   = new ReceiveDataCollection.OnDataAvailableCallback(this.OnDataAvailableHandler);
     this.callbackNotificationQueue = new Queue <CallbackNotificationInformation>();
 }
 internal void ProcessRawData(byte[] data, DataPriorityType priorityType, ReceiveDataCollection.OnDataAvailableCallback callback)
 {
     try
     {
         this.defragmentor.DeserializationContext.LogExtraMemoryUsage(data.Length);
     }
     catch (XmlException)
     {
         PSRemotingTransportException exception = null;
         if (this.isCreateByClientTM)
         {
             exception = new PSRemotingTransportException(PSRemotingErrorId.ReceivedDataSizeExceededMaximumClient, RemotingErrorIdStrings.ReceivedDataSizeExceededMaximumClient, new object[] { this.defragmentor.DeserializationContext.MaximumAllowedMemory.Value });
         }
         else
         {
             exception = new PSRemotingTransportException(PSRemotingErrorId.ReceivedDataSizeExceededMaximumServer, RemotingErrorIdStrings.ReceivedDataSizeExceededMaximumServer, new object[] { this.defragmentor.DeserializationContext.MaximumAllowedMemory.Value });
         }
         throw exception;
     }
     this.recvdData[(int)priorityType].ProcessRawData(data, callback);
 }