Perf update

Cherrypicked from 075f122e1489b1cd1b4f332719e64f80be500021
Re-use same exception for Frame buffering flow control
This commit is contained in:
Chris Boden 2016-02-10 18:55:23 -05:00
parent f9b052d85e
commit 7f532e1747

View File

@ -42,6 +42,14 @@ class WsServer implements HttpServerInterface {
*/ */
private $handshakeNegotiator; private $handshakeNegotiator;
/**
* @var \Closure
*/
private $ueFlowFactory;
/**
* @var \Closure
*/
private $pongReceiver; private $pongReceiver;
/** /**
@ -52,7 +60,6 @@ class WsServer implements HttpServerInterface {
$this->delegate = $component; $this->delegate = $component;
$this->connections = new \SplObjectStorage; $this->connections = new \SplObjectStorage;
// $this->encodingValidator = new \Ratchet\RFC6455\Encoding\Validator;
$this->closeFrameChecker = new \Ratchet\RFC6455\Messaging\CloseFrameChecker; $this->closeFrameChecker = new \Ratchet\RFC6455\Messaging\CloseFrameChecker;
$this->handshakeNegotiator = new \Ratchet\RFC6455\Handshake\ServerNegotiator; $this->handshakeNegotiator = new \Ratchet\RFC6455\Handshake\ServerNegotiator;
@ -61,6 +68,11 @@ class WsServer implements HttpServerInterface {
} }
$this->pongReceiver = function() {}; $this->pongReceiver = function() {};
$reusableUnderflowException = new \UnderflowException;
$this->ueFlowFactory = function() use ($reusableUnderflowException) {
return $reusableUnderflowException;
};
} }
/** /**
@ -94,7 +106,9 @@ class WsServer implements HttpServerInterface {
}, },
function(FrameInterface $frame) use ($wsConn) { function(FrameInterface $frame) use ($wsConn) {
$this->onControlFrame($frame, $wsConn); $this->onControlFrame($frame, $wsConn);
} },
true,
$this->ueFlowFactory
); );
$this->connections->attach($conn, [$wsConn, $streamer]); $this->connections->attach($conn, [$wsConn, $streamer]);