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

Commit

Permalink
Merge bead328 into c018385
Browse files Browse the repository at this point in the history
  • Loading branch information
Metalaka committed Mar 30, 2017
2 parents c018385 + bead328 commit 48cbbd7
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
13 changes: 11 additions & 2 deletions Connection.php
Expand Up @@ -202,6 +202,7 @@ public function __construct(HoaSocket\Connection $connection)
'message',
'binary-message',
'ping',
'close-before',
'close',
'error'
]
Expand Down Expand Up @@ -580,13 +581,21 @@ public function close($code = self::CLOSE_NORMAL, $reason = null)
$protocol = $connection->getCurrentNode()->getProtocolImplementation();

try {
$this->getListener()->fire(
'close-before',
new Event\Bucket([
'code' => $code,
'reason' => $reason
])
);

if (null !== $protocol) {
$protocol->close($code, $reason);
}
} finally {
$out = $connection->disconnect();
$connection->disconnect();
}

return $out;
return;
}
}
2 changes: 2 additions & 0 deletions Test/Unit/Connection.php
Expand Up @@ -121,6 +121,8 @@ public function case_constructor()
->isTrue()
->boolean($listener->listenerExists('ping'))
->isTrue()
->boolean($listener->listenerExists('close-before'))
->isTrue()
->boolean($listener->listenerExists('close'))
->isTrue()
->boolean($listener->listenerExists('error'))
Expand Down

0 comments on commit 48cbbd7

Please sign in to comment.