Quantcast
Channel: Ignite Realtime : All Content - Openfire Plugins
Viewing all articles
Browse latest Browse all 488

Information in Custom XML added to message packet is getting stripped off

$
0
0

I want to add custom xml to an incoming message packet. To do that as part of plugin implementation I have written a PacketInterceptor, which intercepts the message and adds an extension. Till this point everything is fine but when this message is received by the receiver, the information stored in custom xml is striped off. Only the xml element with namespaces is shown.

 

Incoming messages are regular text messages as shown below-

 

<message to='18@mcasax01/SomeResource' from='myroom@conference.mcasax01/testbot2' id='63S0G-27' type='groupchat'>

     <body>Hi</body>

</message>

 

When I add custom xml to this message body, it looks as below after adding the xml in PacketInterceptor logs-

 

<message to='18@mcasax01/SomeResource' from='myroom@conference.mcasax01/testbot2' id='63S0G-27' type='groupchat'>

     <body>Hi</body>

     <data value="imgURL1"/>

</message>

 

But when this message is received by the receiver the value attribute in data is striped off and below message is received by the participant -

 

<message to='17@mcasax01/SomeResource' from='myroom@conference.mcasax01/testbot2' id='63S0G-27' type='groupchat'>

     <body>Hi</body>

     <data xmlns='jabber:client'></data>

</message>

 

Please note that both the text and attributes are getting stripped off from data xml node.

 

Below is java code snippet for your reference-

 

============================

public void interceptPacket(Packet packet, Session session, boolean incoming,

                        boolean processed) throws PacketRejectedException {

// Some code

                                Message messagePacket = (Message) packet;

                                Document document = DocumentHelper.createDocument();

                                Element root = document.addElement("data");

                                Element root1 = root.addAttribute("value", "imgURL1");

                                PacketExtension pe = new PacketExtension(root1);

                                messagePacket.addExtension(pe);

}

============================

 

Any quick help will be highly appreciated.


Viewing all articles
Browse latest Browse all 488

Trending Articles