From 340a0583bfa214ae5a1cb68e72cfb770e98a6af8 Mon Sep 17 00:00:00 2001 From: Michael Friedrich Date: Sat, 15 Sep 2012 14:59:55 +0200 Subject: [PATCH] compatido: cleanup idosocket build, works now with conninfo db hello handshake, still TODO --- components/compatido/Makefile.am | 6 ++++-- components/compatido/idosocket.cpp | 30 +++++++++++++++--------------- 2 files changed, 19 insertions(+), 17 deletions(-) diff --git a/components/compatido/Makefile.am b/components/compatido/Makefile.am index 9ef733811..becebf3d0 100644 --- a/components/compatido/Makefile.am +++ b/components/compatido/Makefile.am @@ -4,9 +4,11 @@ pkglib_LTLIBRARIES = \ compatido.la compatido_la_SOURCES = \ + i2-compatido.h \ + idosocket.cpp \ + idosocket.h \ compatidocomponent.cpp \ - compatidocomponent.h \ - i2-compatido.h + compatidocomponent.h compatido_la_CPPFLAGS = \ $(BOOST_CPPFLAGS) \ diff --git a/components/compatido/idosocket.cpp b/components/compatido/idosocket.cpp index 3fc34207e..3a9623224 100644 --- a/components/compatido/idosocket.cpp +++ b/components/compatido/idosocket.cpp @@ -50,7 +50,7 @@ void IdoSocket::SendMessage(const String& message) * as we inherit all the functionality * of the tcpclient class */ - Write(message, message.size()); + Write(message.CStr(), message.GetLength()); } /** @@ -59,23 +59,23 @@ void IdoSocket::SendMessage(const String& message) */ void IdoSocket::DataAvailableHandler(void) { - for (;;) { - string sString; + String sString; - { - mutex::scoped_lock lock(GetMutex()); + while (NetString::ReadStringFromIOQueue(this, &sString)) { + //std::cerr << "<< " << jsonString << std::endl; - if (!Netstring::ReadStringFromFIFO(GetRecvQueue(), &sString)) - return; - } + try { +// Value value = Value::Deserialize(jsonString); + +// if (!value.IsObjectType()) +// throw_exception(invalid_argument("JSON-RPC message must be a dictionary.")); + +// OnNewMessage(GetSelf(), MessagePart(value)); + } catch (const exception& ex) { + Logger::Write(LogCritical, "jsonrpc", "Exception while processing message from JSON-RPC client: " + String(ex.what())); + } + } - try { - //message = MessagePart(jsonString); - //OnNewMessage(GetSelf(), message); - } catch (const exception& ex) { - Logger::Write(LogCritical, "idosocket", "Exception while processing message from idosocket client: " + string(ex.what())); - } - } } /**