Added simple error hangling to 'SnakeTimer#broadcast'

In some cases the websocket communication fails and Snake#sendMessage throws an exception.
In that case the send loop is interrupted and later clients are not update.
This commit is contained in:
Ulrich von Poblotzki 2013-10-05 15:26:45 +02:00 committed by Dave Syer
parent 84a213f774
commit 386bb73169

View File

@ -79,8 +79,13 @@ public class SnakeTimer {
public static void broadcast(String message) throws Exception {
for (Snake snake : SnakeTimer.getSnakes()) {
snake.sendMessage(message);
}
try {
snake.sendMessage(message);
}
catch (Throwable ex) {
// if Snake#sendMessage fails the client should be removed
}
}
}