aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIvan Enderlin <ivan.enderlin@hoa-project.net>2016-06-15 13:41:28 +0200
committerIvan Enderlin <ivan.enderlin@hoa-project.net>2016-06-17 17:04:44 +0200
commit7710d978cc4bb4793dfb272aac92e0d977984936 (patch)
tree7cfa1549f0c81a00e8781b62a245f88134294ad1
parent599e643c51f14cdf588c832e1d8818ccfd3b394a (diff)
downloadWebsocket-7710d978cc4bb4793dfb272aac92e0d977984936.zip
Websocket-7710d978cc4bb4793dfb272aac92e0d977984936.tar.gz
Websocket-7710d978cc4bb4793dfb272aac92e0d977984936.tar.bz2
Connection: Better safety for `binary-message`.
We apply the same safety strategy to `binary-message` that we did for `message`. We capture all the exceptions than can be thrown and we fire the `error` event listener.
-rw-r--r--Connection.php22
1 files changed, 16 insertions, 6 deletions
diff --git a/Connection.php b/Connection.php
index 0b58a7e..5337bae 100644
--- a/Connection.php
+++ b/Connection.php
@@ -271,12 +271,22 @@ abstract class Connection
if (true === $fromBinary) {
$fromBinary = false;
- $this->getListener()->fire(
- 'binary-message',
- new Event\Bucket([
- 'message' => $frame['message']
- ])
- );
+
+ try {
+ $this->getListener()->fire(
+ 'binary-message',
+ new Event\Bucket([
+ 'message' => $frame['message']
+ ])
+ );
+ } catch (\Exception $e) {
+ $this->getListener()->fire(
+ 'error',
+ new Event\Bucket([
+ 'exception' => $e
+ ])
+ );
+ }
break;
}