Exemplo n.º 1
0
 /// <summary>
 /// Initializes a new instance of the ResponseBody class.
 /// </summary>
 /// <param name="requestBody"></param>
 /// <param name="content"></param>
 public ResponseBody(AMFBody requestBody, object content)
 {
     _requestBody = requestBody;
     _target      = requestBody.Response + AMFBody.OnResult;
     _content     = content;
     _response    = "null";
 }
Exemplo n.º 2
0
	    /// <summary>
		/// Initializes a new instance of the ErrorResponseBody class.
		/// </summary>
		/// <param name="requestBody"></param>
		/// <param name="error"></param>
		public ErrorResponseBody(AMFBody requestBody, string error):base(requestBody)
		{
			IgnoreResults = requestBody.IgnoreResults;
			Target = requestBody.Response + AMFBody.OnStatus;
			Response = null;
			Content = new ExceptionASO(error);
		}
Exemplo n.º 3
0
		/// <summary>
		/// Initializes a new instance of the ResponseBody class.
		/// </summary>
		/// <param name="requestBody"></param>
		/// <param name="content"></param>
		public ResponseBody(AMFBody	requestBody, object content)
		{
			_requestBody = requestBody;
			_target = requestBody.Response + AMFBody.OnResult;
			_content = content;
			_response = "null";
		}
Exemplo n.º 4
0
		/// <summary>
		/// Initializes a new instance of the ErrorResponseBody class.
		/// </summary>
		/// <param name="requestBody"></param>
		/// <param name="message"></param>
		/// <param name="exception"></param>
		public ErrorResponseBody(AMFBody requestBody, IMessage message, Exception exception):base(requestBody)
		{
			ErrorMessage errorMessage = ErrorMessage.GetErrorMessage(message, exception);
			Content = errorMessage;
            Target = requestBody.Response + AMFBody.OnStatus;
			IgnoreResults = requestBody.IgnoreResults;
			Response = "";
		}
Exemplo n.º 5
0
        public ResponseBody GetResponse(AMFBody requestBody)
		{
			for(int i = 0; i < _bodies.Count; i++)
			{
				ResponseBody responseBody = _bodies[i] as ResponseBody;
				if( responseBody.RequestBody == requestBody )
					return responseBody;
			}
			return null;
		}
Exemplo n.º 6
0
		public CachedBody(AMFBody requestBody, IMessage message, object content):base(requestBody, content)
		{
			//Fix content of body for flex messages
			AcknowledgeMessage responseMessage = new AcknowledgeMessage();
			responseMessage.body = content;
			responseMessage.correlationId = message.messageId;
			responseMessage.destination = message.destination;
			responseMessage.clientId = message.clientId;

			this.Content = responseMessage;
		}
Exemplo n.º 7
0
        public CachedBody(AMFBody requestBody, IMessage message, object content) : base(requestBody, content)
        {
            //Fix content of body for flex messages
            AcknowledgeMessage responseMessage = new AcknowledgeMessage();

            responseMessage.body          = content;
            responseMessage.correlationId = message.messageId;
            responseMessage.destination   = message.destination;
            responseMessage.clientId      = message.clientId;

            this.Content = responseMessage;
        }
Exemplo n.º 8
0
 public ResponseBody GetResponse(AMFBody requestBody)
 {
     for (int i = 0; i < _bodies.Count; i++)
     {
         ResponseBody responseBody = _bodies[i] as ResponseBody;
         if (responseBody.RequestBody == requestBody)
         {
             return(responseBody);
         }
     }
     return(null);
 }
Exemplo n.º 9
0
        private AMFBody ReadBody()
        {
            this.Reset();
            string target = base.ReadString();

            // Response that the client understands.
            string response = base.ReadString();
            int    length   = base.ReadInt32();

            try
            {
                object    content   = base.ReadData();
                AMFBody   amfBody   = new AMFBody(target, response, content);
                Exception exception = this.LastError;
                if (exception != null)
                {
                    ErrorResponseBody errorResponseBody = GetErrorBody(amfBody, exception);
                    _failedAMFBodies.Add(errorResponseBody);
#if !SILVERLIGHT
                    if (log.IsFatalEnabled)
                    {
                        log.Fatal(__Res.GetString(__Res.Amf_ReadBodyFail), exception);
                    }
#endif
                    return(null);
                }
                return(amfBody);
            }
            catch (Exception exception)
            {
                //Try to build a valid response from partialy deserialized amf body
                AMFBody           amfBody           = new AMFBody(target, response, null);
                ErrorResponseBody errorResponseBody = GetErrorBody(amfBody, exception);
                _failedAMFBodies.Add(errorResponseBody);
#if !SILVERLIGHT
                if (log.IsFatalEnabled)
                {
                    log.Fatal(__Res.GetString(__Res.Amf_ReadBodyFail), exception);
                }
#endif
                throw;
            }
        }
Exemplo n.º 10
0
		/// <summary>
		/// Initializes a new instance of the ErrorResponseBody class.
		/// </summary>
		/// <param name="requestBody"></param>
		/// <param name="exception"></param>
		public ErrorResponseBody(AMFBody requestBody, Exception exception):base(requestBody)
		{
			if( requestBody.IsEmptyTarget )
			{
				object content = requestBody.Content;
				if( content is IList )
					content = (content as IList)[0];
				IMessage message = content as IMessage;
				//Check for Flex2 messages and handle
				if( message != null )
				{
					ErrorMessage errorMessage = ErrorMessage.GetErrorMessage(message, exception);
					Content = errorMessage;
				}
			}
            if( Content == null )
                Content = new ExceptionASO(exception);
			IgnoreResults = requestBody.IgnoreResults;
            Target = requestBody.Response + AMFBody.OnStatus;
			Response = null;
		}
Exemplo n.º 11
0
 /// <summary>
 /// Initializes a new instance of the CachedBody class.
 /// </summary>
 /// <param name="requestBody"></param>
 /// <param name="content"></param>
 public CachedBody(AMFBody requestBody, object content) : base(requestBody, content)
 {
 }
Exemplo n.º 12
0
        public void WriteMessage(AMFMessage amfMessage)
        {
            try
            {
                base.WriteShort(amfMessage.Version);
                int headerCount = amfMessage.HeaderCount;
                base.WriteShort(headerCount);
                for (int i = 0; i < headerCount; i++)
                {
                    this.WriteHeader(amfMessage.GetHeaderAt(i), ObjectEncoding.AMF0);
                }
                int bodyCount = amfMessage.BodyCount;
                base.WriteShort(bodyCount);
                for (int i = 0; i < bodyCount; i++)
                {
                    ResponseBody responseBody = amfMessage.GetBodyAt(i) as ResponseBody;
                    if (responseBody != null && !responseBody.IgnoreResults)
                    {
                        //Try to catch serialization errors
                        if (this.BaseStream.CanSeek)
                        {
                            long position = this.BaseStream.Position;

                            try
                            {
                                responseBody.WriteBody(amfMessage.ObjectEncoding, this);
                            }
                            catch (Exception exception)
                            {
                                this.BaseStream.Seek(position, SeekOrigin.Begin);
                                //this.BaseStream.Position = position;

#if !SILVERLIGHT
                                if (log.IsFatalEnabled)
                                {
                                    log.Fatal(__Res.GetString(__Res.Amf_SerializationFail), exception);
                                }
#endif

                                ErrorResponseBody errorResponseBody;
                                if (responseBody.RequestBody.IsEmptyTarget)
                                {
                                    object content = responseBody.RequestBody.Content;
                                    if (content is IList)
                                    {
                                        content = (content as IList)[0];
                                    }
                                    IMessage         message          = content as IMessage;
                                    MessageException messageException = new MessageException(exception);
                                    messageException.FaultCode = __Res.GetString(__Res.Amf_SerializationFail);
                                    errorResponseBody          = new ErrorResponseBody(responseBody.RequestBody, message, messageException);
                                }
                                else
                                {
                                    errorResponseBody = new ErrorResponseBody(responseBody.RequestBody, exception);
                                }

                                try
                                {
                                    errorResponseBody.WriteBody(amfMessage.ObjectEncoding, this);
                                }
#if !SILVERLIGHT
                                catch (Exception exception2)
                                {
                                    if (log.IsFatalEnabled)
                                    {
                                        log.Fatal(__Res.GetString(__Res.Amf_ResponseFail), exception2);
                                    }
                                    throw;
                                }
#else
                                catch (Exception)
                                {
                                    throw;
                                }
#endif
                            }
                        }
                        else
                        {
                            responseBody.WriteBody(amfMessage.ObjectEncoding, this);
                        }
                    }
                    else
                    {
                        AMFBody amfBody = amfMessage.GetBodyAt(i);
                        dotFlex.Util.ValidationUtils.ObjectNotNull(amfBody, "amfBody");
                        amfBody.WriteBody(amfMessage.ObjectEncoding, this);
                    }
                }
            }
#if !SILVERLIGHT
            catch (Exception exception)
            {
                if (log.IsFatalEnabled)
                {
                    log.Fatal(__Res.GetString(__Res.Amf_SerializationFail), exception);
                }
                throw;
            }
#else
            catch (Exception)
            {
                throw;
            }
#endif
        }
Exemplo n.º 13
0
		/// <summary>
		/// Initializes a new instance of the ResponseBody class.
		/// </summary>
		/// <param name="requestBody"></param>
		public ResponseBody(AMFBody	requestBody)
		{
			_requestBody = requestBody;
		}
Exemplo n.º 14
0
 public bool ContainsResponse(AMFBody requestBody)
 {
     return(GetResponse(requestBody) != null);
 }
Exemplo n.º 15
0
 /// <summary>
 /// Initializes a new instance of the ResponseBody class.
 /// </summary>
 /// <param name="requestBody"></param>
 public ResponseBody(AMFBody requestBody)
 {
     _requestBody = requestBody;
 }
Exemplo n.º 16
0
        public bool ContainsResponse(AMFBody requestBody)
		{
			return GetResponse(requestBody) != null;
		}
Exemplo n.º 17
0
		/// <summary>
		/// Initializes a new instance of the CachedBody class.
		/// </summary>
		/// <param name="requestBody"></param>
		/// <param name="content"></param>
		public CachedBody(AMFBody requestBody, object content):base(requestBody, content)
		{
		}
Exemplo n.º 18
0
		/// <summary>
		/// Initializes a new instance of the ErrorResponseBody class.
		/// </summary>
		/// <param name="requestBody"></param>
		/// <param name="message"></param>
		/// <param name="errorMessage"></param>
		public ErrorResponseBody(AMFBody requestBody, IMessage message, ErrorMessage errorMessage):base(requestBody)
		{
			Content = errorMessage;
            Target = requestBody.Response + AMFBody.OnStatus;
			IgnoreResults = requestBody.IgnoreResults;
			Response = "";
		}
Exemplo n.º 19
0
 /// <summary>
 /// Adds a body to the AMF packet.
 /// </summary>
 /// <param name="body">The body object to add.</param>
 public void AddBody(AMFBody body)
 {
     this._bodies.Add(body);
 }
Exemplo n.º 20
0
		public DescribeService(AMFBody amfBody)
		{
			_amfBody = amfBody;
		}