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.
pull/79/head
Ulrich von Poblotzki 11 years ago committed by Dave Syer
parent 84a213f774
commit 386bb73169

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

Loading…
Cancel
Save