From 2ece53dde926b75cdcc2965bcfc855b6fadec447 Mon Sep 17 00:00:00 2001 From: Metalaka Date: Mon, 15 Feb 2016 21:12:24 +0100 Subject: [PATCH] Server: Fix throws exceptions while broadcasting messages. While broadcasting a message to some nodes an error can occur because the node connection is closed but isn't yet removed from the *to send* list. Here we will catch these exceptions to allow the server to continue working. --- Connection.php | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/Connection.php b/Connection.php index 4dc88ef..3eb2246 100644 --- a/Connection.php +++ b/Connection.php @@ -287,12 +287,21 @@ protected function _run(HoaSocket\Node $node) break; } - $this->getListener()->fire( - 'message', - new Event\Bucket([ - 'message' => $frame['message'] - ]) - ); + try { + $this->getListener()->fire( + 'message', + new Event\Bucket([ + 'message' => $frame['message'] + ]) + ); + } catch (HoaException\Group $e) { + $this->getListener()->fire( + 'error', + new Event\Bucket([ + 'exception' => $e + ]) + ); + } break; } else {