Replaced Connection::getId() with resourceId property
This commit is contained in:
parent
f98cda3e29
commit
4654acb7d6
@ -162,6 +162,7 @@ class IOServerComponent implements MessageComponentInterface {
|
|||||||
$new_connection = new Connection($new_socket);
|
$new_connection = new Connection($new_socket);
|
||||||
|
|
||||||
$new_connection->remoteAddress = $new_socket->getRemoteAddress();
|
$new_connection->remoteAddress = $new_socket->getRemoteAddress();
|
||||||
|
$new_connection->resourceId = (int)substr((string)$new_socket->getResource(), strrpos((string)$new_socket->getResource(), '#') + 1);
|
||||||
|
|
||||||
$this->_resources[] = $new_connection->getSocket()->getResource();
|
$this->_resources[] = $new_connection->getSocket()->getResource();
|
||||||
$this->_connections[$new_connection->getSocket()->getResource()] = $new_connection;
|
$this->_connections[$new_connection->getSocket()->getResource()] = $new_connection;
|
||||||
|
@ -16,13 +16,6 @@ class Connection implements ConnectionInterface {
|
|||||||
$this->_socket = $socket;
|
$this->_socket = $socket;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return int
|
|
||||||
*/
|
|
||||||
public function getID() {
|
|
||||||
return (int)(string)$this->_socket;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This is here because I couldn't figure out a better/easier way to tie a connection and socket together for the server and commands
|
* This is here because I couldn't figure out a better/easier way to tie a connection and socket together for the server and commands
|
||||||
* Anyway, if you're here, it's not recommended you use this/directly interact with the socket in your App...
|
* Anyway, if you're here, it's not recommended you use this/directly interact with the socket in your App...
|
||||||
|
@ -2,8 +2,4 @@
|
|||||||
namespace Ratchet\Resource;
|
namespace Ratchet\Resource;
|
||||||
|
|
||||||
interface ConnectionInterface {
|
interface ConnectionInterface {
|
||||||
/**
|
|
||||||
* @return int
|
|
||||||
*/
|
|
||||||
function getId();
|
|
||||||
}
|
}
|
@ -43,7 +43,7 @@ class IOServerComponentTest extends \PHPUnit_Framework_TestCase {
|
|||||||
$this->_server->onOpen($master);
|
$this->_server->onOpen($master);
|
||||||
$clone = $this->_decorated->_conn_open;
|
$clone = $this->_decorated->_conn_open;
|
||||||
|
|
||||||
$this->assertEquals($master->getID() + 1, $clone->getID());
|
$this->assertEquals($master->resourceId + 1, $clone->resourceId);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testOnMessageSendsToApp() {
|
public function testOnMessageSendsToApp() {
|
||||||
|
@ -12,7 +12,7 @@ class FakeSocket implements SocketInterface {
|
|||||||
public $_last = array();
|
public $_last = array();
|
||||||
|
|
||||||
public function getResource() {
|
public function getResource() {
|
||||||
return null;
|
return "#{$this->_id}";
|
||||||
}
|
}
|
||||||
|
|
||||||
public function __toString() {
|
public function __toString() {
|
||||||
|
Loading…
Reference in New Issue
Block a user