]> git.tdb.fi Git - r2c2.git/blobdiff - source/network/server.cpp
Better handling of network communication errors
[r2c2.git] / source / network / server.cpp
index a892dedd25a85c79e9ba8edd1f3c60db767855a6..c60eb70e109f296ccad3a820f10df62c958a6798 100644 (file)
@@ -124,16 +124,7 @@ void Server::send(const P &pkt)
 {
        for(vector<Connection *>::const_iterator i=connections.begin(); i!=connections.end(); ++i)
                if(!(*i)->stale && (*i)->comm.is_handshake_done())
-               {
-                       try
-                       {
-                               (*i)->comm.send(pkt);
-                       }
-                       catch(...)
-                       {
-                               (*i)->stale = true;
-                       }
-               }
+                       (*i)->comm.send(pkt);
 }
 
 
@@ -144,6 +135,7 @@ Server::Connection::Connection(Server &s, Net::StreamSocket *o):
 {
        socket->signal_end_of_file.connect(sigc::mem_fun(this, &Connection::end_of_file));
        comm.signal_handshake_done.connect(sigc::mem_fun(this, &Connection::handshake_done));
+       comm.signal_error.connect(sigc::mem_fun(this, &Connection::comm_error));
        comm.initiate_handshake();
 }
 
@@ -279,6 +271,11 @@ void Server::Connection::receive(const TrainRoutePacket &pkt)
        }
 }
 
+void Server::Connection::comm_error(const exception &)
+{
+       stale = true;
+}
+
 void Server::Connection::error(const string &msg)
 {
        ErrorPacket pkt;