2016-04-12 14 views
0

'da Smack API istemcisi tarafından iletiyle ek parametre göndermek istiyorum EJabberd XMPP sunucusu olarak kullanıyorum ve smack API'da xmpp istemcisi oluşturuyorum. İletiyle ek parametre göndermek istiyorum. Bu şifreye göreejabberd

public static void main(String[] args) throws SmackException,IOException,XMPPException { 

     XMPPTCPConnectionConfiguration config = XMPPTCPConnectionConfiguration.builder() 
        .setResource("Smack") 
        .setSecurityMode(SecurityMode.disabled) 
        .setServiceName("localhost") 
        .setHost("localhost") 
        .setPort(Integer.parseInt("5222")) 
        .build(); 
       AbstractXMPPConnection conn = new XMPPTCPConnection(config); 
       try {           
        conn.setPacketReplyTimeout(10000); 
        SASLAuthentication.unBlacklistSASLMechanism("PLAIN"); 
        SASLAuthentication.blacklistSASLMechanism("SCRAM-SHA-1"); 
        SASLAuthentication.blacklistSASLMechanism("DIGEST-MD5"); 
        //SASLAuthentication. 
        conn.connect(); 
        conn.login("[email protected]","123456"); 
        System.out.println("login successfull"); 
        Message message = new Message(); 
        String stanza = "i am vip";     
        message.setBody(stanza); 
        stanza+= "<type>.jpg</type>"; 
        ChatManager manager = ChatManager.getInstanceFor(conn); 
         manager.createChat("[email protected]").sendMessage(message); 
        message.setBody(stanza); 
        System.out.println("Message Sent"); 

       } catch (Exception e) { 
        e.printStackTrace(); 
       } 

    } 

i xmpp stanza türünü eklemek mümkün ama ben mesaj ile ek bir parametre göndermek için ihtiyaç way.So tercih edilmemektedir düşünüyorum:

Kodum altındadır. Çözüme ulaşırsam bu takdir edilecektir. Teşekkürler!

cevap

2

Eğer ki-

Message message = new Message(); 
        String stanza = "i am vip";     
        message.setBody(stanza); 
message.addBody("customtag","Custom tag value"); 
message.addBody("customtag1","Custom tag value1"); 

gibi ek bir parametre ekleyebilir ve bunu

String customtageValue= message.getBody("customtag"); 

for more detail check this link

gibi- alabilirsiniz
İlgili konular