使用jabber IMCore API进行群聊

时间:2015-08-05 23:40:37

标签: xmpp multiuserchat

我正在尝试运行CAXL API以将IM集成到我的网页中。我尝试过使用材料设计的新jabberwerx演示,但群聊不起作用。点击"邀请小组聊天"按钮,调用一个尝试进入聊天室的方法,但是永远不会触发成功回调错误回调。

Javascript代码:

          _enterRoom: function(nickname) {
            /**
             * jabberwerx.MUCRoom.enter takes the nickname we want to
             * enter the room with and an addition argument object that
             * may define callbacks fired when the asynchronous function
             * completes. Since we have an event handler bound to the
             * roomEntered event all we need is an error callback in case
             * the server did not allow the room's creation.
             *
             * enter may also throw exaceptions for invalid arguments or
             * bad state so it should be wrapped in a try-catch.
             *
             * see ../api/symbols/jabberwerx.MUCRoom.html#enter
             */

            var enterRoomArgs = {
                successCallback: _app._onRoomEnterSuccess,
                errorCallback: _app._onRoomEnterError
            };
            try {
                log("JWA", "entering room");
                _app.room.enter(nickname, enterRoomArgs);
                return(true);
            } catch (ex) {
                log("JWA", "Error attempting to enter room: " + ex.message);
                _app.room.destroy();
                _app.room = null;
                return(false);
            }
        },

        _onRoomEnterSuccess: function() {
            log("JWA", "successfully entered room");
        },

        _onRoomEnterError: function(err, aborted) {
//            $("#muchatroom").dialog("close");
            log("JWA", 'Error entering room: ' + err.message);
            if (_app.room != null) {
                _app.room.exit();
                _app.room.destroy();
                _app.room = null;
            }
        },

        _broadcastMessage: function() {
            //room.isActive returns true if we have fully entered the room.
            if (_app.room == null || !_app.room.isActive()) {
                myalert("Please enter a chat room before attempting to broadcast");
                return;
            }
            var body = $("#broadcasttext").val();
            if (!body) {
                log("JWA", "send has empty message");
                return;
            }
            try {
                _app.room.sendBroadcast($("#broadcasttext").val());
            } catch (ex) {
                myalert(ex.message);
            }
            $("#broadcasttext").val("");
            $("#broadcasttext").focus();
            //       $("#muchtext").append(chat);
        },

0 个答案:

没有答案