Fix event arguments
This commit is contained in:
parent
b8967b999a
commit
22e500d02a
@ -24,6 +24,7 @@ class IoServer {
|
|||||||
/**
|
/**
|
||||||
* Array of React event handlers
|
* Array of React event handlers
|
||||||
* @var \SplFixedArray
|
* @var \SplFixedArray
|
||||||
|
* @deprecated exists BC only, now unused
|
||||||
*/
|
*/
|
||||||
protected $handlers;
|
protected $handlers;
|
||||||
|
|
||||||
@ -53,9 +54,6 @@ class IoServer {
|
|||||||
$socket->on('connection', array($this, 'handleConnect'));
|
$socket->on('connection', array($this, 'handleConnect'));
|
||||||
|
|
||||||
$this->handlers = new \SplFixedArray(3);
|
$this->handlers = new \SplFixedArray(3);
|
||||||
$this->handlers[0] = array($this, 'handleData');
|
|
||||||
$this->handlers[1] = array($this, 'handleEnd');
|
|
||||||
$this->handlers[2] = array($this, 'handleError');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -100,9 +98,16 @@ class IoServer {
|
|||||||
|
|
||||||
$this->app->onOpen($conn->decor);
|
$this->app->onOpen($conn->decor);
|
||||||
|
|
||||||
$conn->on('data', $this->handlers[0]);
|
$that = $this;
|
||||||
$conn->on('end', $this->handlers[1]);
|
$conn->on('data', function ($data) use ($conn, $that) {
|
||||||
$conn->on('error', $this->handlers[2]);
|
$that->handleData($data, $conn);
|
||||||
|
});
|
||||||
|
$conn->on('close', function () use ($conn, $that) {
|
||||||
|
$that->handleEnd($conn);
|
||||||
|
});
|
||||||
|
$conn->on('error', function (\Exception $e) use ($conn, $that) {
|
||||||
|
$that->handleError($e, $conn);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user