Hi to all, I apologize for mistakes or silly questions but I’'m a Smack+Jabber newbie.
I’'m trying to send an xhtml message within a Java (rel. 1.5.0_06) application using Smack (rel. 3.0.2) to a Spark client (rel. 2.5.2) through a OpenFire server (rel. 3.3.1).
OpenFire and Spark are on the same windows box and the Java client is on another windows box; both are on the same subnet.
The Java client sends the message, the Spark client receives the message but doesn’'t visualize it; I say that it receives the message because in the “show traffic window” is listed the received message with the following body:
!!!
+
The Java client code is:
package com.ti.lab.qos.test.jabber;
import org.jivesoftware.smack.*;
import org.jivesoftware.smack.packet.Message;
import org.jivesoftware.smack.Chat;
import org.jivesoftware.smackx.XHTMLManager;
import org.jivesoftware.smackx.XHTMLText;
public class SimpleClient {
public void simpleClient() {};
/**
- @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
String msg = “test message”;
SimpleClient sc = new SimpleClient();
sc.sendMsg(msg);
}
public void sendMsg(String msg){
XMPPConnection conn1;
try {
XMPPConnection.DEBUG_ENABLED = true;
// Create a connection to the jabber.org server on a specific port.
conn1 = new XMPPConnection(new ConnectionConfiguration(“10.229.7.99”, 5222));
conn1.connect();
// Login as a user
conn1.login(“QoSServiceAdmin”, “QoSServiceAdmin”);
// Create a chat for sending/receiving messages
ChatManager newChatMan = conn1.getChatManager();
Chat newChat = newChatMan.createChat("user1@10.229.7.99", new MyMessageListener());
Message message = new Message();
message.setSubject(“QoS Service notify”);
//message.setBody(“Would you like to see the requested content with QoS ?”);
// Create an XHTMLText to send with the message
XHTMLText xhtmlText = new XHTMLText(null, null);
xhtmlText.appendOpenParagraphTag(“font-size:large”);
xhtmlText.append("Hey user1, this is my new ");
xhtmlText.appendOpenSpanTag(“color:green”);
xhtmlText.append(“green”);
xhtmlText.appendCloseSpanTag();
xhtmlText.appendOpenEmTag();
xhtmlText.append("!!!");
xhtmlText.appendCloseEmTag();
xhtmlText.appendCloseParagraphTag();
// Add the XHTML text to the message
XHTMLManager.addBody(message, xhtmlText.toString());
newChat.sendMessage(message);
for(long i=1; i<900000000; i++){}
conn1.disconnect();
} catch (XMPPException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
Any suggestion?
Thank you
Rob