Skip to content
This repository was archived by the owner on Sep 20, 2021. It is now read-only.

Commit 08060f7

Browse files
committed
Connection: Catch disconnection of a node earlier.
While broadcasting a message, some under disconnecting node can be reached. This context throws an exception and we try to close this node. This is wrong because this is too late. This is possible to catch this exception earlier and avoid the whole disconnection process once again (which is redundant).
2 parents ee104f5 + 2ece53d commit 08060f7

File tree

1 file changed

+15
-6
lines changed

1 file changed

+15
-6
lines changed

Connection.php

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -287,12 +287,21 @@ protected function _run(HoaSocket\Node $node)
287287
break;
288288
}
289289

290-
$this->getListener()->fire(
291-
'message',
292-
new Event\Bucket([
293-
'message' => $frame['message']
294-
])
295-
);
290+
try {
291+
$this->getListener()->fire(
292+
'message',
293+
new Event\Bucket([
294+
'message' => $frame['message']
295+
])
296+
);
297+
} catch (HoaException\Group $e) {
298+
$this->getListener()->fire(
299+
'error',
300+
new Event\Bucket([
301+
'exception' => $e
302+
])
303+
);
304+
}
296305

297306
break;
298307
} else {

0 commit comments

Comments
 (0)