From abd00de4a4bb395fd2b66c53c150471e7d8ed8b6 Mon Sep 17 00:00:00 2001 From: Mateusz Piekos Date: Mon, 2 Jul 2012 13:23:59 +0200 Subject: Added handling of responses from request IQ Fixed bug with hanging session requests after one of client crash diff --git a/Swiften/Whiteboard/OutgoingWhiteboardSession.cpp b/Swiften/Whiteboard/OutgoingWhiteboardSession.cpp index 585a689..2de4ec4 100644 --- a/Swiften/Whiteboard/OutgoingWhiteboardSession.cpp +++ b/Swiften/Whiteboard/OutgoingWhiteboardSession.cpp @@ -6,6 +6,7 @@ #include +#include #include #include @@ -19,10 +20,17 @@ namespace Swift { void OutgoingWhiteboardSession::startSession() { boost::shared_ptr payload = boost::make_shared(WhiteboardPayload::SessionRequest); boost::shared_ptr > request = boost::make_shared >(IQ::Set, toJID_, payload, router_); + request->onResponse.connect(boost::bind(&OutgoingWhiteboardSession::handleRequestResponse, this, _1, _2)); request->send(); } std::string OutgoingWhiteboardSession::getClientID() const { return "a"; } + + void OutgoingWhiteboardSession::handleRequestResponse(boost::shared_ptr payload, ErrorPayload::ref error) { + if (error) { + onSessionCancelled(toJID_); + } + } } diff --git a/Swiften/Whiteboard/OutgoingWhiteboardSession.h b/Swiften/Whiteboard/OutgoingWhiteboardSession.h index 3d0dd1a..5cc0f42 100644 --- a/Swiften/Whiteboard/OutgoingWhiteboardSession.h +++ b/Swiften/Whiteboard/OutgoingWhiteboardSession.h @@ -21,5 +21,8 @@ namespace Swift { virtual ~OutgoingWhiteboardSession(); void startSession(); std::string getClientID() const; + + private: + void handleRequestResponse(boost::shared_ptr payload, ErrorPayload::ref error); }; } diff --git a/Swiften/Whiteboard/WhiteboardSessionManager.cpp b/Swiften/Whiteboard/WhiteboardSessionManager.cpp index 3cb1cc3..2e519e0 100644 --- a/Swiften/Whiteboard/WhiteboardSessionManager.cpp +++ b/Swiften/Whiteboard/WhiteboardSessionManager.cpp @@ -47,8 +47,8 @@ namespace Swift { WhiteboardSession::ref session = getSession(to); if (!session) { OutgoingWhiteboardSession::ref outgoingSession = createOutgoingSession(to); - outgoingSession->startSession(); onSessionRequest(to, true); + outgoingSession->startSession(); return outgoingSession; } else { return session; -- cgit v0.10.2-6-g49f6