mxmbsocket/lib/Ratchet/Command/SendMessage.php
Chris Boden 51d0516aa3 Cleanup
Application stack working!
Existing unit tests fixed
Implemented HyBi-10 unframing
2011-10-28 14:12:39 -04:00

30 lines
718 B
PHP

<?php
namespace Ratchet\Command;
use Ratchet\SocketCollection;
class SendMessage implements CommandInterface {
protected $_sockets;
protected $_message = '';
public function __construct(SocketCollection $sockets) {
$this->_sockets = $sockets;
}
public function setMessage($msg) {
$this->_message = (string)$msg;
}
public function getMessage() {
return $this->_message;
}
public function execute() {
if (empty($this->_message)) {
throw new \UnexpectedValueException("Message is empty");
}
foreach ($this->_sockets as $current) {
$current->write($this->_message, strlen($this->_message));
}
}
}