[jdev] Smack API and jabber.org

viju1983 viju1983.3ngj10 at no-mx.jabberforum.org
Wed Feb 11 12:56:52 CST 2009

Hi All,

I am very new to Smack API. I have started using it from last one month
only. So If you find this as a silly question, just dont feel bad and
help me out to make my Application work.

Application Description.

I am building an IM client with Openfire as my chat server and I am
communicating with openfire through the Smack API. I am also using the
Spark client parallely foir testing purpose.

I am able to do the following things.

1) Login
2) Populate my friend's list from Roster
3) Detect the presence of my friends.
4) Get the Chat history of my friends(Currently everything is coming as
null.but timestamp is displayed properly)

Problem Description

1) When I am sending the message from a user to another user, It is not
able to send the Message. I suppose the flow is broken in the 
sendMessage method of the Chat Class.
2) When I am sending the message, I am getting back a null from the

I am pasting my send and process method below

public void send(String sender, String message) throws XMPPException {
			Chat chat = fChat.getChat();// This is getting a chat object
			if(chat!=null) {
				System.out.println("Sending message to " + sender + "
				Message msg = new Message();
				chat.sendMessage(msg);// I think it is broken in this line only

public void process(Chat chat, Message message) {
		String from = message.getFrom();
		int slashIndex = from.indexOf("/");
		slashIndex = slashIndex == -1 ? from.length() : slashIndex;
		from = from.substring(0, slashIndex);
		FriendChat fChat = (FriendChat) this.friendChatMap.get(from);
		String msg = message.getBody();
		fChat.addMessage(msg, false);
"{from:'"+toSimpleUserId(from)+"',message:'"+msg+"'}");// this publish
is used to publish this message to the client

Could you please point out what can be the problem with this code.

Believe me I have followed all the basic rules of Smack API

Thanks in Advance


viju1983's Profile: http://www.jabberforum.org/member.php?userid=17427
View this thread: http://www.jabberforum.org/showthread.php?t=1306

More information about the JDev mailing list