2012-12-25 1 views
-1

세션 첨부를 포함해야하는 XMPP 웹 응용 프로그램에서 작업 중입니다. Openfire XMPP 서버를 사용하고 있습니다. 세션이 생성되고 세션의 sid 및 제거를 가져 오는 서버 측 첨부 파일을 성공적으로 구현했습니다. 불행히도, 나는 다음 부분에 갇혀있다.Strophe 세션 첨부 - 403 금지됨

아시다시피 sid와 rid를 얻은 후에 strophe.Connection.attach()를 사용하여 strphe를 기존 세션에 첨부해야합니다. 그 후에 서버로부터 올바른 응답을 얻는 IQ 요청을하고 있습니다. 그러나 상태가 변경되지 않습니다. 앱이 연결되어 있지 않고 연결되어 있지 않으므로 아무 것도 할 수 없습니다. IQ 요청 후 서버는 정상적인 메시지로 응답하고 다음 요청에서 403 금지 된 오류가 발생하고 연결이 종료됩니다.

<body xmlns="http://jabber.org/protocol/httpbind"> 
<iq id="6173:sendIQ" xmlns="jabber:client" type="result" from="ghost" to="[email protected]/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> 

이 응답 세션이 유효하다는 것을 말하는가 : 나는 IQ 요청에 때라도 응답을

var BOSH_SERVICE = 'http://localhost/cosys-rtw/'; 
var connection = null; 
var sid = ""; 
var rid = 0; 
function notifyUser(msg) 
{ 
    if (msg.getAttribute('from') == "[email protected]/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 = "[email protected]"; 
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());} 
        });} 

: 여기

는 코드입니다. 내가 맞습니까? 저는이 일을 이해할 수 없으므로 지금 이것을 지역 사회에 넘겨주고 있습니다. By the way - 메리 크리스마스

답변