Hi,
I want to generate a message with an application-specific error (according to the XMPP Core RFC, section 9.3.4. or XEP-0182):
<message from='island-chess@games.shakespeare.lit' to='miranda@shakespeare.lit/desktop'type='error'> <turn xmlns='[http://jabber.org/protocol/mug#user](http://jabber.org/protocol/mug#user)'> <play xmlns='[http://jabber.org/protocol/mug/chess](http://jabber.org/protocol/mug/chess)'/> </turn> <error type='cancel'> <undefined-condition xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/> <invalid-turn xmlns='[http://jabber.org/protocol/mug'/](http://jabber.org/protocol/mug'/)> </error> </message>
However I don’t find a method in the org.xmpp.packet.PacketError class to realize this.
Best Regards
I solve my problem by this workaround:
` /**
Generate an application-secific error.
@param type The error type.
@param appErrorName The name of the application specific XML element.
@param appErrorNS The namespace of the application specific XML element.
@return The application specific error.
*/
private PacketError createApplicationSpecificError(
PacketError.Type type, String appErrorName,
String appErrorNS) {
// Create the error element by hand
Element error = DocumentFactory.getInstance().createElement(“error”);
error.addAttribute(“type”, type==null?null:type.toXMPP());
error.addAttribute(
“code”,
Integer.toString(
PacketError.Condition.undefined_condition.getLegacyCode()));
Element conditionElement = DocumentFactory.getInstance().createElement(
PacketError.Condition.undefined_condition.toXMPP(),
“urn:ietf:params:xml:ns:xmpp-stanzas”);
error.add(conditionElement)
if (appErrorName != null && appErrorNS != null) {
error.add(DocumentFactory.getInstance().createElement(
appErrorName, appErrorNS));
}
return new PacketError(error);
}`
But it would be great if we extend the PacketError for this error type.
I wrote a patch for the PacketError class to add support for application-specific error conditions. It would be great if it gets into the trunk of Openfire or start a discussion about that topic.
Best Regards
addApplicationCondition.patch (3397 Bytes)
Hi,
Thanks, I have filed it: JM-1536 , hopefully your contribution provokes some discussion
daryl
guus
June 23, 2009, 7:07am
5
Guenther’s patch has been committed to SVN. The changes will be part of the upcoming 1.1 release of Tinder.