0

I want to integrate XMPP chat into my website. Tried to create just a bare bone chat, where it should auto login and auto open a chat window. It just can auto login, but does nothing after that.

The whole code is as below. Why it does not auto open a chat window?

<body>


<script>
    converse.initialize({
        show_controlbox_by_default: true,
        allow_muc: false,
        show_controlbox_by_default: true,
        auto_login: true,
        authentication: 'login',
        jid: 'kelvin@xmpp.mydomainhere.com',
        password: 'kelvin',
        websocket_url: 'wss://xmpp.mydomainhere.com:5280/websocket'
    });

    console.log("000");

    converse.plugins.add('myplugin', {
        initialize: function () {
            this._converse.chats.open('jacky@xmpp.mydomainhere.com')

            var msg = converse.env.$msg({
                from: 'kelvin@xmpp.mydomainhere.com',
                to:'jacky@xmpp.mydomainhere.com',
                type:'chat'
            });
            this._converse.send(msg);
        }
    });

    </script>

    </body>

Dopinder
  • 11
  • 3

1 Answers1

0

From version 3.0.0 and onwards, plugins need to be whitelisted (via the whitelisted_plugins setting), otherwise they are not initialized.

So you simply have to add whitelisted_plugins: ['myplugin'] to your converse.initialize call.

Besides that, you also need to register the plugin before calling converse.initialize.

JC Brand
  • 2,652
  • 18
  • 18
  • I added the whitelisted_plugins, as following, but it still does not work. Any help? Thanks. converse.initialize({ whitelisted_plugins: ['myplugin'], show_controlbox_by_default: true, allow_muc: false, auto_login: true, authentication: 'login', jid: 'kelvin@xmpp.mydomainhere.com', password: 'kelvin', websocket_url: 'wss://xmpp.mydomainhere.com:5280/websocket' }); – Dopinder Apr 13 '17 at 06:22
  • You need to register the plugin before calling converse.initialize. I updated my answer. – JC Brand Apr 13 '17 at 09:47
  • I have switched the two code blocks. Now the plugin block comes before the converse.initialize block. But it still does not work. – Dopinder Apr 14 '17 at 04:52