libt2n: (gerd) fix exception passing
[libt2n] / src / command_server.cpp
index 15a19a7..3bfc0e3 100644 (file)
 #include <boost/archive/xml_oarchive.hpp>
 #include <boost/archive/xml_iarchive.hpp>
 #include <boost/serialization/serialization.hpp>
-#include <boost/serialization/export.hpp>
 
 #include "command_server.hxx"
 #include "container.hxx"
+#include "log.hxx"
 
 using namespace std;
 
@@ -39,6 +39,8 @@ namespace libt2n
 /// handle a command including deserialization and answering
 void command_server::handle_packet(const std::string& packet, server_connection* conn)
 {
+    OBJLOGSTREAM(s,debug,"handling packet from connection " << conn->get_id());
+
     // deserialize packet
     istringstream ifs(packet);
     boost::archive::binary_iarchive ia(ifs);
@@ -47,6 +49,14 @@ void command_server::handle_packet(const std::string& packet, server_connection*
     // TODO: catch
     ia >> ccont;
 
+    std::ostream* ostr;
+    if ((ostr=s.get_logstream(fulldebug))!=NULL)
+    {
+        (*ostr) << "decoded packet data: " << std::endl;
+        boost::archive::xml_oarchive xo(*ostr);
+        xo << BOOST_SERIALIZATION_NVP(ccont);
+    }
+
     // TODO: cast to command subclass (template)
     command *cmd=ccont.get_command();
 
@@ -72,6 +82,13 @@ void command_server::handle_packet(const std::string& packet, server_connection*
     // TODO: catch
     oa << res;
 
+    if ((ostr=s.get_logstream(fulldebug))!=NULL)
+    {
+        (*ostr) << "returning result, decoded data: " << std::endl;
+        boost::archive::xml_oarchive xo(*ostr);
+        xo << BOOST_SERIALIZATION_NVP(res);
+    }
+
     conn->write(ofs.str());
 }