Esempio 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";
 }
Esempio 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);
		}
Esempio n. 3
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 = "";
		}
Esempio n. 4
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;
		}
Esempio n. 5
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 = "";
		}
Esempio n. 6
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      = "";
 }
Esempio n. 7
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);
 }
Esempio n. 8
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      = "";
        }
Esempio n. 9
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);
 }
Esempio n. 10
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;
        }
Esempio n. 11
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;
		}
Esempio n. 12
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;
            }
        }
Esempio n. 13
0
        private ErrorResponseBody GetErrorBody(AMFBody amfBody, Exception exception)
        {
            ErrorResponseBody errorResponseBody = null;

            try {
                object content = amfBody.Content;
                if (content is IList)
                {
                    content = (content as IList)[0];
                }
                if (content is GodLesZ.Library.Amf.Messaging.Messages.IMessage)
                {
                    errorResponseBody = new ErrorResponseBody(amfBody, content as GodLesZ.Library.Amf.Messaging.Messages.IMessage, exception);
                }
                else
                {
                    errorResponseBody = new ErrorResponseBody(amfBody, exception);
                }
            } catch {
                errorResponseBody = new ErrorResponseBody(amfBody, exception);
            }
            return(errorResponseBody);
        }
Esempio n. 14
0
 /// <summary>
 /// Initializes a new instance of the ResponseBody class.
 /// </summary>
 /// <param name="requestBody"></param>
 public ResponseBody(AMFBody requestBody)
 {
     _requestBody = requestBody;
 }
Esempio n. 15
0
		/// <summary>
		/// Initializes a new instance of the ResponseBody class.
		/// </summary>
		/// <param name="requestBody"></param>
		public ResponseBody(AMFBody requestBody) {
			_requestBody = requestBody;
		}
Esempio n. 16
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);
 }
Esempio n. 17
0
 public bool ContainsResponse(AMFBody requestBody)
 {
     return(GetResponse(requestBody) != null);
 }
Esempio n. 18
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);
                        GodLesZ.Library.Amf.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
        }
Esempio n. 19
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";
		}
Esempio n. 20
0
		public DescribeService(AMFBody amfBody) {
			_amfBody = amfBody;
		}
Esempio n. 21
0
		public bool ContainsResponse(AMFBody requestBody) {
			return GetResponse(requestBody) != null;
		}
Esempio n. 22
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)
 {
 }