XMPP - Facebook - How can my client implementation receive messages sent by other client implementations?

StackOverflow https://stackoverflow.com/questions/15025615

Question

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.

Was it helpful?

Solution

If you send an IQ to enable the feature the server replies with a <feature-not-implemented /> error IQ, which as specified here means it is not supporting XEP 0280. I just checked myself through the Audium XML console.

IQ:

<iq xmlns='jabber:client'
from='my.facebook.username@chat.facebook.com/Mac-Pro-di-Michele_65563c5f_4D689E59FB8A5' 
to='chat.facebook.com'
type='set'
id='enable1'>
  <enable xmlns='urn:xmpp:carbons:2'/>
</iq>

Reply:

<iq xmlns='jabber:client'
from='chat.facebook.com'
to='my.facebook.username@chat.facebook.com/Mac-Pro-di-Michele_65563c5f_4D689E59FB8A5' type='error'
id='enable1'>
  <enable xmlns='urn:xmpp:carbons:2'/>
  <error code='501' type='cancel'>
    <feature-not-implemented xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/>
  </error>
</iq>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top