Skip to content

Commit

Permalink
Improved Socket Service for PHP 5.3.
Browse files Browse the repository at this point in the history
  • Loading branch information
andot committed Jul 30, 2016
1 parent 93ae8bc commit 5c68a24
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/Hprose/Socket/Service.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* *
* hprose socket Service library for php 5.3+ *
* *
* LastModified: Jul 30, 2016 *
* LastModified: Jul 31, 2016 *
* Author: Ma Bingyao <[email protected]> *
* *
\**********************************************************/
Expand Down Expand Up @@ -172,8 +172,9 @@ private function getOnReceive($server, $socket) {
$onSend(pack("NN", $dataLength | 0x80000000, $id) . $data);
}
};
$userFatalErrorHandler = &$this->userFatalErrorHandler;
return function()
use ($self, $server, $socket, &$bytes, &$headerLength, &$dataLength, &$id, $send) {
use ($self, $server, $socket, &$bytes, &$headerLength, &$dataLength, &$id, &$userFatalErrorHandler, $send) {
$data = @fread($socket, $self->readBuffer);
if ($data === false) {
$self->error($server, $socket, 'Unknown read error');
Expand Down Expand Up @@ -204,7 +205,7 @@ private function getOnReceive($server, $socket) {
if (($dataLength >= 0) && (($length - $headerLength) >= $dataLength)) {
$context = $self->createContext($server, $socket);
$data = substr($bytes, $headerLength, $dataLength);
$self->userFatalErrorHandler = function($error) use ($self, $send, $context) {
$userFatalErrorHandler = function($error) use ($self, $send, $context) {
$send($self->endError($error, $context));
};
$self->defaultHandle($data, $context)->then(function($data) use ($send) {
Expand Down

0 comments on commit 5c68a24

Please sign in to comment.