strophe.js group invite - handler not triggered

1.4k views Asked by At

I have problem with my invitation handler. It is never fired. I can see invitation from group:

<body xmlns='http://jabber.org/protocol/httpbind'>
        <message xmlns="jabber:client" from="[email protected]" to="[email protected]">
            <x xmlns="http://jabber.org/protocol/muc#user">
                <invite from="[email protected]">
                    <reason>Please join me in conference.</reason>
                </invite>
            </x>
            <x xmlns="jabber:x:conference" jid="[email protected]"/>
        </message>
</body>

but on_message handler is not fired. Because no type is defined.

When I put Chat.connection.addHandler(Chat.on_message,null, "message", null,null,null,null);

Invitations is shown but then all messages group or chat are handled by this. I want to me able to have

Chat.connection.addHandler(Chat.on_message,null, "message", "chat");
Chat.connection.addHandler(Chat.on_message,null, "message", "groupchat");

for separate type of messages.

I am going around i circles for two days with this. Help!?

In other words what to put in addHandler for messages that contain invite?

UPDATE

I have to put

Chat.connection.addHandler(Chat.on_message,null, "message"); 

before I did invite.

I do not understand why is that? Does anyone has idea?

1

There are 1 answers

4
Mark S On BEST ANSWER

The 2 handlers you started with require a type. The invite does not have a type. The handler I use for invites looks for the namespace instead. That way it's separated from my message handler.

connection.addHandler(onInvite, 'jabber:x:conference');