Quantcast
Channel: Ignite Realtime : Discussion List - All Communities
Viewing all articles
Browse latest Browse all 10742

Receiving custom message

$
0
0

Hello,

 

I'm developping an android application which use smack.

I receive a complex packet, and i need to interpret it..

I tried to use packet.toXML() but this function truncate my packet.

So i saw that i must implement my own provider and packetextension, i tried this but it doesn't work;

The packet i received is :

 

<message>   <commande xmlns="urn:xmpp:crisalid:commande:update" id="1" recap="False" modified="2014-01-02T17:59:00.894" version="434" etat="2" uid="178F76C702424A8F919B495625A90B59" reserve="False">      <ticket type="TAB" version="2" imprime="N" caisse="0" attente="N" annule="N" numero="0" uid="{178F76C7-0242-4A8F-919B-495625A90B59}" memo="N" devise="EURO">         <entete>            <creation iso="2014-01-02T17:59:00.847">               <date>02/01/2014</date>               <heure>17:59:00</heure>            </creation>            <modification iso="2014-01-02T17:59:00.894">               <date>02/01/2014</date>               <heure>17:59:00</heure>            </modification>          </entete>     </ticket>    </commande></message>

 

I already did that :

 

publicclass CommandePacketExtension implements PacketExtension {    publicstaticfinal String NAMESPACE = "urn:xmpp:crisalid:commande:update";    private String id,recap,modified,version,etat,uid,reserve;      public CommandePacketExtension(String id,String recap,String modified,String version,String etat,String uid,String reserve)    {        this.id = id;        this.recap=recap;        this.modified=modified;        this.version=version;        this.etat=etat;        this.uid=uid;        this.reserve=reserve;    }      public String getId()    {        return id;    }      public String getRecap()    {        return recap;    }      public String getModified()    {        return modified;    }      public String getVersion()    {        return version;    }      public String getEtat() {        return etat;    }      public String getUid()    {        return uid;    }      public String getReserve()    {        return reserve;    }      @Override    public String getElementName() {        return"commande";    }      @Override    public String getNamespace() {        returnnull;    }      @Override    public String toXML() {        return"<commande xmlns='" + NAMESPACE +               " id=" + id +               " modified=" + modified +               " version=" + version +               " etat=" + etat +               " uid=" + uid +               " reserve=" + reserve +               "/>" +               "</commande>";    }} 

 

and

 

publicclass CommandePacketProvider extends EmbeddedExtensionProvider {    @Override    protected PacketExtension createReturnExtension(String s, String s2, Map<String, String> attributeMap, List<? extends PacketExtension> packetExtensions) {        returnnew CommandePacketExtension(attributeMap.get("id"),attributeMap.get("recap"),attributeMap.get("modified")        ,attributeMap.get("version"),attributeMap.get("etat"),attributeMap.get("uid"),attributeMap.get("reserve"));    }} 

 

and

 

 pm.addExtensionProvider("commande", CommandePacketExtension.NAMESPACE,new CommandePacketProvider());

 

So with that i can see : <commande xmlns="urn:xmpp:crisalid:commande:update" id="1" recap="False" modified="2014-01-02T17:59:00.894" version="434" etat="2" uid="178F76C702424A8F919B495625A90B59" reserve="False"> in my logcat but if i do the same think for ticket, entete, it doesn't work;

 

I need to do a class for each one, or a parser or...


Viewing all articles
Browse latest Browse all 10742

Trending Articles