I have implemented a facebook chat client that connect using the Smack API. At this moment, the main features are working well. I send, receive messages, receive typing notifications... But I have a problem. If I'm talking to someone using my client, I receive the messages I sent to the contact within the facebook's chat. But if send a message to the contact via facebook's chat, my client doesn't receive that message. If the contact answers me, I receive his message, but the dialogue becomes incomplete, since it just shows the messages the contact sent, but it doesn't show the message I sent within another XMPP client.
Since the facebook shows the messages sent by my client, I think it's possible to do the same. I'm really new to XMPP and I need some help to figure out how can I do this.
My code looks like this right now:
Receiving messages:
connection.getChatManager().addChatListener(
new ChatManagerListener(){
@Override
void chatCreated(Chat chat, boolean createdLocally) {
if(!createdLocally){
chat.addMessageListener(messageListener)
}
}
}
)
The message listener just pass the message via push to my Javascript Client.
Sending messages:
public boolean sendMessage(String jid, String message){
FacebookContact contact = mapJIDContact.get(jid)
try{
if (contact != null && (connection != null) && (connection.isConnected())) {
ChatManager chatManager = connection.getChatManager();
if(contact.chat == null){
contact.chat = chatManager.createChat(jid, messageListener);
}
contact.chat.sendMessage(message);
return true
}
return false
}
catch (XMPPException e){
return false
}
}
The FacebookContact is a class created by me. It stores some contact informations and the Chat, if it was already opened.
EDIT:
I found that this feature I want is provided by this XMPP extension: http://xmpp.org/extensions/xep-0280.html. I'm trying to find if the facebook chat implements this extension.