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;
bbbb.patch (939 Bytes)

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

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;
    }

XMPPConnection.as (31767 Bytes)