Skip to content
Snippets Groups Projects
Commit 61b39686 authored by jpbl's avatar jpbl
Browse files

Now the client works perfectly

parent e1798f89
No related branches found
No related tags found
No related merge requests found
......@@ -13,7 +13,7 @@ CLEANFILES = \
test_LDFLAGS = $(QT_LDFLAGS) $(X_LDFLAGS) -static
test_LDADD = ../../../utilspp/libutilspp.la -lpthread $(LIBQT)
KDE_CXXFLAGS = $(USE_EXCEPTIONS)
AM_CPPFLAGS = $(QT_INCLUDES) $(X_INCLUDES) -I$(top_srcdir)
AM_CPPFLAGS = $(QT_INCLUDES) $(X_INCLUDES) -I$(top_srcdir)/src
......
......@@ -20,6 +20,7 @@
#include <sstream>
#include "global.h"
#include "request.h"
#include "requester.h"
......@@ -32,16 +33,31 @@ Request::Request(const std::string &sequenceId,
{}
void
Request::onError(const std::string &, const std::string &)
{}
Request::onError(const std::string &code, const std::string &message)
{
_debug("Received an error:\n Code: %s\n SequenceID: %s\n Message%s\n",
code.c_str(),
mSequenceId.c_str(),
message.c_str());
}
void
Request::onEntry(const std::string &, const std::string &)
{}
Request::onEntry(const std::string &code, const std::string &message)
{
_debug("Received a temp info:\n Code: %s\n SequenceID: %s\n Message%s\n",
code.c_str(),
mSequenceId.c_str(),
message.c_str());
}
void
Request::onSuccess(const std::string &, const std::string &)
{}
Request::onSuccess(const std::string &code, const std::string &message)
{
_debug("Received a success:\n Code: %s\n SequenceID: %s\n Message%s\n",
code.c_str(),
mSequenceId.c_str(),
message.c_str());
}
std::string
Request::toString()
......
......@@ -30,7 +30,7 @@ RequesterImpl::RequesterImpl()
, mSessionIdCount(0)
, mSequenceIdCount(0)
{
registerObject< AccountRequest >(std::string("register"));
registerObject< Request >(std::string("register"));
}
SessionIO *
......
......@@ -18,6 +18,7 @@
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include "global.h"
#include "sessionio.h"
InputStreamer::InputStreamer(SessionIO *sessionIO)
......@@ -30,6 +31,8 @@ InputStreamer::run()
while(mSessionIO->isUp()) {
mSessionIO->receive();
}
_debug("The Session input is down.\n");
}
OutputStreamer::OutputStreamer(SessionIO *sessionIO)
......@@ -42,6 +45,8 @@ OutputStreamer::run()
while(mSessionIO->isUp()) {
mSessionIO->send();
}
_debug("The Session output is down.\n");
}
SessionIO::SessionIO(std::istream *input, std::ostream *output)
......@@ -105,17 +110,33 @@ SessionIO::receive(std::string &answer)
void
SessionIO::send()
{
if(!mOutput->good()) {
mMutex.lock();
mIsUp = false;
mMutex.unlock();
}
else {
(*mOutput) << mOutputPool.pop();
mOutput->flush();
}
}
void
SessionIO::receive()
{
if(!mInput->good()) {
mMutex.lock();
mIsUp = false;
mMutex.unlock();
}
else {
std::string s;
std::getline(*mInput, s);
if(s.size() > 0) {
mInputPool.push(s);
}
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment