libt2n: (gerd) fix client-connection-logic, finish wrappers, all tests are working...
[libt2n] / src / client_wrapper.hxx
index 672308e..ebc9e25 100644 (file)
@@ -59,9 +59,10 @@ class ConnectionWrapper
 
         virtual client_connection* get_connection()=0;
 
-        virtual void handle(command_client* stubBase, boost::function< void() > f)
+        virtual bool handle(command_client* stubBase, boost::function< void() > f)
         {
             f();
+            return true;
         }
 
         long long get_command_timeout_usec(void)
@@ -179,7 +180,7 @@ class T2nSingletonWrapper : public T2nSingletonWrapperMessages
             if (WrappedConnection.get() == NULL)
                 throw std::logic_error(NotInitializedMessage);
 
-            std::auto_ptr<Client> stub(new Client(*(WrappedConnection->get_connection()),
+            std::auto_ptr<Client> stub(new Client(WrappedConnection->get_connection(),
                 WrappedConnection->get_command_timeout_usec(),
                 WrappedConnection->get_hello_timeout_usec()));
 
@@ -193,8 +194,17 @@ class T2nSingletonWrapper : public T2nSingletonWrapperMessages
             ensure_singleton_there();
 
             typename detail::TypeWrap<R>::type result;
+
+            // bind our Client-object and the local result
             detail::Call<R> call( boost::bind( f, SingletonObject->Stub.get()), result );
-            WrappedConnection->handle(SingletonObject->Stub.get(),call);
+
+            // let the wrapper-handler call the fully-bound function
+            if (!WrappedConnection->handle(SingletonObject->Stub.get(),call))
+            {
+                // create an result with default-constructor if the handler could not
+                // successfully do a call but no exception occured
+                result=typename detail::TypeWrap<R>::type();
+            }
             return result;
         }