I want to implements chatstate so the receiver can know another user is typing or not.
I've added this code for create chat
Mychat = ChatManager.getInstanceFor(connection).createChat("testadmin@domain.com"), mMessageListener);
I use this to set chatState
ChatStateManager.getInstance(connection).setCurrentState(ChatState.composing, Mychat);
and last code to receive message and get chatState
private class MMessageListener implements ChatMessageListener, ChatStateListener{
Context ctx;
public MMessageListener(Context context) {
ctx=context;
}
public void processMessage(final org.jivesoftware.smack.chat.Chat chat,
final Message message) {
//message received success..
}
@Override
public void stateChanged(Chat arg0, ChatState arg1) {
Log.d("Chat State","typing status run..");
if (ChatState.composing.equals(arg1)) {
Log.d("Chat State",arg0.getParticipant() + " is typing..");
} else if (ChatState.gone.equals(arg1)) {
Log.d("Chat State",arg0.getParticipant() + " has left the conversation.");
} else {
Log.d("Chat State",arg0.getParticipant() + ": " + arg1.name());
}
}
}
I've added all the code in and it's receiving the composing state back, but only after I've sent the message, so the state is arriving with the message itself, which isn't much good for a someone is typing type message, how i get typing state real time when someone is typing before send the message ?
I use smack 4.1.5, and openfire as server
best regard.