-1

セッションの添付ファイルを含める必要があるXMPPWebアプリケーションに取り組んでいます。OpenfireXMPPサーバーを使用しています。セッションが作成され、sidを取得してセッションを削除するサーバー側の添付ファイルを正常に実装しました。残念ながら、私は次の部分で立ち往生しています。

私が知っているように、sidを取得して削除した後、Strophe.Connection.attach()を使用してstrpheを既存のセッションにアタッチする必要があります。その後、サーバーから正しい応答を取得するIQリクエストを作成しています。ただし、ステータスに変更がありません。つまり、アプリが接続も接続もされていないため、何もできません。IQリクエストの後、サーバーは通常のメッセージで時間どおりに応答し、次のリクエストで403 forbiddenエラーが発生し、接続が終了します。

コードは次のとおりです。

var BOSH_SERVICE = 'http://localhost/cosys-rtw/';
var connection = null;
var sid = "";
var rid = 0;
function notifyUser(msg) 
{
    if (msg.getAttribute('from') == "testuser1@ghost/pingstream") {
        var elems = msg.getElementsByTagName('body');
        var body = elems[0];
        $('#notifications').append(Strophe.getText(body));
}
return true;
}

 function onConnect(status)
{
    console.log("Connect")
console.log(status)
if (status == Strophe.Status.ATTACHED) {
    $('#notifications').html('<p class="welcome">Hello! Any new posts will    appear below.</p>');
    connection.addHandler(notifyUser, null, 'message', null, null,  null);
    connection.send($pres().tree());
}       
}

$(document).ready(function () {
 $.ajax({'url':'http://localhost/x',
        'method':'get',
        'success':function(response){
            console.log(response);  
            console.log(jQuery.parseJSON(response));
            resp = jQuery.parseJSON(response);
            window.sid = resp.sid;
            window.rid = resp.rid;
            prepareStrophe();               
        }});
});

 function prepareStrophe(){
console.log(BOSH_SERVICE);
jid = "testuser1@ghost";
connection = new Strophe.Connection(BOSH_SERVICE);
console.log(window.rid);
console.log(window.sid);
connection.attach(  jid,window.sid,window.rid,null);
connection.sendIQ( $iq({to:Strophe.getDomainFromJid(jid),type:"get"})
                    .c('query',{xmlns:'http://jabber.org/protocol/disco#info'}),
                    function(){
                        if (status == Strophe.Status.ATTACHED) {
                    connection.send($pres().tree());}
                    });}

IQリクエストに対して次の応答があります。

<body xmlns="http://jabber.org/protocol/httpbind">
 <iq id="6173:sendIQ" xmlns="jabber:client" type="result" from="ghost"    to="testuser1@ghost/6b8bfe07">
 <query xmlns="http://jabber.org/protocol/disco#info">
 <identity category="server" name="Openfire Server" type="im"></identity>
 <identity category="pubsub" type="pep"></identity>
 <feature var="http://jabber.org/protocol/pubsub#delete-nodes"></feature>
  .
  .
  .
 <feature var="http://jabber.org/protocol/pubsub#purge-nodes"></feature>
 <feature var="http://jabber.org/protocol/disco#info"></feature>
 <feature var="http://jabber.org/protocol/rsm"></feature>
</query>
</iq>
</body>

この応答は、セッションが有効であることを示しています。私は正しいですか?私はこれを理解することができないので、今私はこれをコミュニティに手渡しています。ちなみに-メリークリスマス

4

1 に答える 1

1

誰かが同じ問題を抱えているなら、私はここで共有したい何かを持っていると思います。ignite realtime http://community.igniterealtime.org/thread/33004のこのスレッドでは、この問題について説明しています。そこに記載されている設定は私にとってはうまくいきました。

于 2012-12-26T23:27:37.217 に答える