实施smack API,现在尝试获取聊天状态,例如用户是Composing
,Paused
等。到目前为止我做了什么
public class IncomingChatListener implements ChatMessageListener, ChatStateListener {
@Override
public void stateChanged(Chat chat, ChatState state) {
Log.d("-----","into chat state");
if (ChatState.composing.equals(state)) {
Log.d("Chat State",chat.getParticipant() + " is typing..");
} else if (ChatState.gone.equals(state)) {
Log.d("Chat State",chat.getParticipant() + " has left the conversation.");
} else {
Log.d("Chat State",chat.getParticipant() + ": " + state.name());
}
}
public void processMessage(Chat chat, Message message) {
.......
......
}
当用户输入时,我发送的状态如下:
ChatStateManager.getInstance(connection).setCurrentState(ChatState.composing, myChat);
问题是stateChanged
函数永远不会被调用,而是在processMessage
函数中收到了像composing等..的chatStatus数据包。
如何在stateChanged
函数中收到它?