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

Commit

Permalink
Connection: Catch disconnection of a node earlier.
Browse files Browse the repository at this point in the history
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).
  • Loading branch information
Hywan committed Feb 24, 2016
2 parents ee104f5 + 2ece53d commit 08060f7
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions Connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 08060f7

Please sign in to comment.