Skip navigation
2208 Views 2 Replies Latest reply: Jun 17, 2009 2:19 PM by Matt Towers RSS
NakoRuru1982 Bronze 47 posts since
Dec 21, 2007
Currently Being Moderated

Mar 2, 2009 7:14 PM

can XMPPConnection doesn't fire error event when it meets message with error type

Hi,

 

  Below is a patch file for XMPPConnection.as, you can also read it from attachment. I'm sorry that I could not set background color for text.

 

  As you can see, I want XMPPConnection not to fire error event when it meets a message with error type. Because I wish a message with error type has its own logic.

 

  Thanks,

 

 

 

  Index: H:/toybrick/xiff/src/org/jivesoftware/xiff/core/XMPPConnection.as
===================================================================
--- H:/toybrick/xiff/src/org/jivesoftware/xiff/core/XMPPConnection.as    (revision 10963)
+++ H:/toybrick/xiff/src/org/jivesoftware/xiff/core/XMPPConnection.as    (working copy)
@@ -800,11 +800,11 @@
                 throw new SerializationException();
             }
             // ADDED in error handling for messages
-            if( msg.type == Message.ERROR_TYPE ) {
-                var exts:Array = msg.getAllExtensions();
-                dispatchError( msg.errorCondition, msg.errorMessage, msg.errorType, msg.errorCode, exts.length > 0 ? exts[0] : null);
-            }
-            else
+//            if( msg.type == Message.ERROR_TYPE ) {
+//                var exts:Array = msg.getAllExtensions();
+//                dispatchError( msg.errorCondition, msg.errorMessage, msg.errorType, msg.errorCode, exts.length > 0 ? exts[0] : null);
+//            }
+//            else
             {
                 var event:MessageEvent = new MessageEvent();
                 event.data = msg;

Attachments:
  • Sean Voisen KeyContributor 93 posts since
    Mar 9, 2005

    Thanks! I'll add this to the JIRA feature requests.

    • Matt Towers Bronze 55 posts since
      Jan 14, 2009

      Here's a fix.  I also fixed a minor bug in the logger.debug statement such that the stanza xml will be written out insteaf of  "[object Message]"

      Note that the XIFFError is still broadcasted for backwards compatability.

       

      replace handleMessage() in XMPPConnection.as[794]

       

              protected function handleMessage( node:XMLNode ):Message
              {
                  var msg:Message = new Message();
                  logger.debug("MESSAGE: {0}", msg.getNode().toString()); //Typidee:  write out message xml instead of just "[object Message]"
                  // Populate with data
                  if( !msg.deserialize( node ) ) {
                      throw new SerializationException();
                  }
                  // ADDED in error handling for messages
                  if( msg.type == Message.ERROR_TYPE ) {
                      var exts:Array = msg.getAllExtensions();
                      dispatchError( msg.errorCondition, msg.errorMessage, msg.errorType, msg.errorCode, exts.length > 0 ? exts[0] : null);
                     
                  }

       

                  // typidee.com:  Don't suppress MessageEvent(s) of Message.ERROR_TYPE
                  var event:MessageEvent = new MessageEvent();
                  event.data = msg;
                  dispatchEvent( event );       

       

                  return msg;
              }

      Attachments:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points