mxmbsocket/lib/Ratchet/Resource/Connection/Connection.php
Chris Boden 5386b4c066 Folder restructure
Just reorganized the folders.  Namespacing broken, unit tests broken, nothing works.
2011-11-12 14:29:10 -05:00

39 lines
916 B
PHP

<?php
namespace Ratchet\Server;
use Ratchet\SocketInterface;
/**
* @todo Should I build the commands into this class? They'd be executed by the Server...
*/
class Connection implements ConnectionInterface {
/**
* @var int
*/
protected $_id;
protected $_data = array();
public function __construct(SocketInterface $socket) {
$this->_id = (string)$socket->getResource();
$this->_id = (int)substr($this->_id, strrpos($this->_id, '#') + 1);
}
/**
* @return int
*/
public function getID() {
return $this->_id;
}
public function set($name, $val) {
$this->_data[$name] = $val;
}
public function get($name) {
if (!isset($this->_data[$name])) {
throw new \UnexpectedValueException("Attribute '{$name}' not found in Connection {$this->getID()}");
}
return $this->_data[$name];
}
}