mxmbsocket/lib/Ratchet/Command/Action/Runtime.php
Chris Boden d880d29729 Refactoring
Refactored Command/Composite pattern, now as expected
Server recursively executes commands
Above changes fixed issues of server/client not being notified on forced disconnects
2011-11-07 16:02:01 -05:00

33 lines
795 B
PHP

<?php
namespace Ratchet\Command\Action;
use Ratchet\Command\ActionInterface;
use Ratchet\SocketInterface;
use Ratchet\SocketObserver;
class Runtime implements ActionInterface {
/**
* @var SocketInterface
*/
protected $_socket;
/**
* @var Closure
*/
protected $_command = null;
public function __construct(SocketInterface $socket) {
$this->_socket = $socket;
}
/**
* Your closure should accept a single \Ratchet\Socket parameter
* @param Closure Your closure/lambda to execute when the time comes
*/
public function setCommand(\Closure $callback) {
$this->_command = $callback;
}
public function execute(SocketObserver $scope = null) {
return call_user_func($this->_command, $socket);
}
}