Sending messages: Invalid XML data (bug?)

It seems a bug in Messages.as:

Sending a message using

myRoom.sendMessage( "hello" );

or

myConnection.sendMessage("hello");

pushes an invalid XML to my server (note the attribute xmlns):

<message to="XXX@conference.XXX.com" type="groupchat" id="m_9"><body>hello</body> xmlns="http://jabber.org/protocol/chatstates"</message>

But it has to be like the follow (note the “active” node):

<message to="XXX@conference.XXX.com" type="groupchat" id="m_12"><body>hello</body><active xmlns="http://jabber.org/protocol/chatstates" /></message>

It seem this issue based on an bug in Messages.as, which causes in the getter method “state()”. Sending a message a state is by default null and the getter method doesn’t handle it in a right way. It just create an invalid XML mentioned above.

To fix this issue, the constructor of Message has to include a default state, which should not be null. (Note the new value for chatState ):

public function Message( recipient:EscapedJID = null,
msgID:String = null,
msgBody:String = null,
msgHTMLBody:String = null,
msgType:String = null,
msgSubject:String = null,
chatState:String = ChatState.ACTIVE )

My configuration:

Thanks!

-Jens

http://www.websector.de

Sorry for the late reply, but there is no “sendMessage” in any of the connection classes.

There is one in Room.

Could you provide more of your code which is resulting this behaviour?

As I cannot seem to see the problem.

You are right, a connection class have not a sendMessage method.

Anyway, I did mean room.sendMessage(); And there I have had some issues, which causes of a null value of chatState:String in the constructor of Message.

To avoid this issue, it has to be chatState:String = ChatState.ACTIVE. Please check out again the details and code I posted above.

-Jens

www.websector.de



  var msg5:Message = new Message( new EscapedJID("room@conference.server.com/sender"), null, "I am afraid of the dark",
         null, Message.TYPE_GROUPCHAT );
  trace("room body: " + msg5.body);
  trace("room htmlBody: " + msg5.htmlBody);
  trace("room state: " + msg5.state);
  trace("room subject: " + msg5.subject);
  trace("room thread: " + msg5.thread);
  trace("room time: " + msg5.time);
  trace("room getNode(): " + msg5.getNode().toString());

Results:

room body: I am afraid of children
Error : null trapped. Resuming.
room htmlBody: null
room state: null
room subject: null
room thread: null
room time: null
room getNode(): I am afraid of children

Sorry, but I cant seem to find your error.

Are you using the latest trunk version from svn?

At the current revision 11562 the bug seems to be gone. When I posted this bug in October last year I was using r 11343.

-Jens