
Refactored Command/Composite pattern, now as expected Server recursively executes commands Above changes fixed issues of server/client not being notified on forced disconnects
20 lines
478 B
PHP
20 lines
478 B
PHP
<?php
|
|
namespace Ratchet\Protocol\WebSocket\Command\Action;
|
|
use Ratchet\SocketInterface;
|
|
use Ratchet\Command\Action\SendMessage;
|
|
use Ratchet\SocketObserver;
|
|
|
|
class Disconnect extends SendMessage {
|
|
protected $_code = 1000;
|
|
|
|
public function setStatusCode($code) {
|
|
$this->_code = (int)$code;
|
|
|
|
// re-do message based on code
|
|
}
|
|
|
|
public function execute(SocketObserver $scope = null) {
|
|
parent::execute();
|
|
$this->_socket->close();
|
|
}
|
|
} |