Create a client session when requested by server. Ignore presence from the same resource.
git-svn-id: http://yate.null.ro/svn/yate/trunk@2279 acf43c95-373e-0410-b603-e72c3f656dc1
This commit is contained in:
parent
528ad83535
commit
1a95c86897
|
@ -1280,10 +1280,36 @@ void JBStream::processStarted(XMLElement* xml)
|
|||
TelEngine::destruct(jidxml);
|
||||
TelEngine::destruct(bind);
|
||||
if (err == XMPPError::NoError)
|
||||
changeState(Running);
|
||||
// Create session if required
|
||||
if (m_remoteFeatures.get(XMPPNamespace::Session)) {
|
||||
XMLElement* iq = XMPPUtils::createIq(XMPPUtils::IqSet,0,0,"sess_1");
|
||||
iq->addChild(XMPPUtils::createElement(XMLElement::Session,
|
||||
XMPPNamespace::Session));
|
||||
m_waitState = WaitSessionRsp;
|
||||
sendStreamXML(iq,state());
|
||||
}
|
||||
else
|
||||
changeState(Running);
|
||||
else
|
||||
INVALIDXML_AND_EXIT(err,reason)
|
||||
}
|
||||
else if (m_waitState == WaitSessionRsp) {
|
||||
// Accept iq result or error
|
||||
if (xml->type() != XMLElement::Iq)
|
||||
DROP_AND_EXIT
|
||||
// Check if received correct type
|
||||
XMPPUtils::IqType t = XMPPUtils::iqType(xml->getAttribute("type"));
|
||||
if (t != XMPPUtils::IqResult && t != XMPPUtils::IqError)
|
||||
DROP_AND_EXIT
|
||||
// Check if received correct id for the current waiting state
|
||||
if (!xml->hasAttribute("id","sess_1"))
|
||||
DROP_AND_EXIT
|
||||
// Terminate on error
|
||||
if (t == XMPPUtils::IqError)
|
||||
ERRORXML_AND_EXIT
|
||||
// Result
|
||||
changeState(Running);
|
||||
}
|
||||
else
|
||||
DROP_AND_EXIT
|
||||
TelEngine::destruct(xml);
|
||||
|
@ -2192,6 +2218,13 @@ void JBClientStream::processRunning(XMLElement* xml)
|
|||
bool avail = pres == JBPresence::None;
|
||||
if (avail || pres == JBPresence::Unavailable) {
|
||||
if (event->from().resource()) {
|
||||
// Check for our own resource: we've seen that
|
||||
if (event->from().resource() == local().resource()) {
|
||||
Debug(engine(),DebugAll,
|
||||
"Stream. Ignoring presence from the same resource [%p]",this);
|
||||
m_events.remove(event,true);
|
||||
return;
|
||||
}
|
||||
JIDResource* res = m_roster->resources().get(event->from().resource());
|
||||
if (pres == JBPresence::Unavailable) {
|
||||
if (res)
|
||||
|
|
|
@ -574,7 +574,8 @@ protected:
|
|||
WaitStart, // Started stream start response
|
||||
WaitFeatures, // Started stream features
|
||||
WaitBindRsp, // Started wait for bind response
|
||||
WaitTlsRsp, // Started: wait response to starttls
|
||||
WaitSessionRsp, // Started wait for session response
|
||||
WaitTlsRsp, // Started wait response to starttls
|
||||
WaitChallenge, // Auth iq auth query with auth data sent, wait response
|
||||
WaitResponse, // Auth iq auth query sent, wait response
|
||||
WaitAborted, // Auth abort sent, wait confirmation to terminate stream
|
||||
|
|
Loading…
Reference in New Issue