]> git.tdb.fi Git - libs/net.git/blobdiff - source/net/communicator.h
Massive overhaul of the Protocol class
[libs/net.git] / source / net / communicator.h
index 8530db128d26c5d168d99fb0af34e7c874484ffc..5921767e6a37ada58ba91876f5a2b80a30c3c59a 100644 (file)
@@ -19,6 +19,7 @@ class Communicator
 {
 public:
        sigc::signal<void> signal_handshake_done;
+       sigc::signal<void, const std::exception &> signal_error;
 
 private:
        StreamSocket &socket;
@@ -46,8 +47,18 @@ public:
                        throw sequence_error("connection aborted");
                if(handshake_status!=2)
                        throw sequence_error("handshaking not done");
-               unsigned size = protocol.assemble(pkt, out_buf, buf_size);
-               socket.write(out_buf, size);
+               unsigned size = protocol.serialize(pkt, out_buf, buf_size);
+               try
+               {
+                       socket.write(out_buf, size);
+               }
+               catch(const std::exception &e)
+               {
+                       good = false;
+                       if(signal_error.empty())
+                               throw;
+                       signal_error.emit(e);
+               }
        }
 
 private: