2011-09-13 3 views
3

페이지로드시 XMPP 연결을 만들 수 있습니다. 그러나 다른 페이지로 이동할 때마다 동일한 연결을 사용하여 클라이언트에서 반복되는 알림을 제거하려고합니다. 다음 코드를 사용했습니다. XMPP strophe 연결 연결 프로세스가 실패했습니다.

$(document).bind('connect', function (ev, data) { 
    var jid = $.jStorage.get('JID', null); 
    var sid = $.jStorage.get('SID', null); 
    var rid = $.jStorage.get('RID', null); 
    if ((jid != null) && (sid != null) && (rid != null)) { 
     var conn = new Strophe.Connection("http://localhost:5280/xmpp-httpbind"); 
     conn.attach(jid, sid, rid, function() { 
      alert('Connection attach success.'); 
      Gab.connection = conn; 
     }); 
    } 
    else { 
     var conn = new Strophe.Connection("http://localhost:5280/xmpp-httpbind"); 
     conn.connect(data.jid, data.password, function (status) { 
      if (status === Strophe.Status.CONNECTED) { 
       $(document).trigger('connected'); 
      } else if (status === Strophe.Status.DISCONNECTED) { 
       $(document).trigger('disconnected'); 
      } 
     }); 
     Gab.connection = conn; 
    } 
}); 

그리고 언로드에

는 :

$(window).unload(function() { 
    if (Gab.connection != null) { 
     Gab.connection.pause(); 
     $.jStorage.set('JID', Gab.connection.jid); 
     $.jStorage.set('SID', Gab.connection.sid); 
     $.jStorage.set('RID', Gab.connection.rid); 
    } else { 
     $.jStorage.flush(); 
    } 
// Gab.connection = null; 
    alert('paused/disconnected'); 
}) 

그것은 연결에 연결, 그러나 즉시이 부착, 그것은 방화범 콘솔에서 (POST http://localhost:5280/xmpp-httpbind 404 찾을 수 없음 36ms에게) 말했다. 어떤 아이디어?

미리 감사드립니다.

+0

어떤 서버가 사용 되었습니까? – Zash

+0

해결책을 얻었습니까? – Hunt

답변

0

메시지 본문을 검사하십시오. 일부 XMPP 서버는 종료시 HTTP 404를 반환합니다.

0

언로드를 신뢰해서는 안됩니다. 대신 xmpp 서버의 모든 cb에 RID를 저장/업데이트하십시오. 각 통화마다 RID가 증가하는지 확인하십시오.