We're updating the issue view to help you get more done. 

Fire events for ERROR types in messages

Description

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;

Environment

None

Acceptance Test - Entry

None

Activity

Show:
Matt Towers
June 18, 2009, 2:24 AM

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

Juga Paazmaya
January 14, 2010, 2:54 PM

Seems this has been in trunk for a while

Fixed

Assignee

Sean Voisen

Reporter

Sean Voisen

Labels

None

Expected Effort

None

Ignite Forum URL

None

Components

Fix versions

Affects versions

Priority

Trivial
Configure