本文整理汇总了PHP中Connection::getId方法的典型用法代码示例。如果您正苦于以下问题:PHP Connection::getId方法的具体用法?PHP Connection::getId怎么用?PHP Connection::getId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Connection
的用法示例。
在下文中一共展示了Connection::getId方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: addConnection
public function addConnection(Connection $connection)
{
if (!isset($this->connections[$connection->getId()])) {
$this->connections[$connection->getId()] = $connection;
}
return $this;
}
示例2: connect
/**
* Registers the socket with a new Connection object and stores that
* @param resource The socket for the new client
*/
private function connect($clientSocket)
{
$connection = new Connection($clientSocket);
$this->connections[$connection->getId()] = $connection;
$this->sockets[$connection->getId()] = $clientSocket;
//we throw a new event to handle new connections
$onConnectingEvent = new \System\Web\Websocket\Event\OnConnectingEvent();
$onConnectingEvent->setServer($this);
$onConnectingEvent->setConnection($connection);
$onConnectingEvent->raise();
}
示例3: checkRequestsPerMinute
/**
* NOT idempotent, call once per data
*
* @param Connection $connection
*/
protected function checkRequestsPerMinute($connection)
{
$id = $connection->getId();
if (!isset($this->requests[$id])) {
$this->requests[$id] = array();
}
// Add current token
$this->requests[$id][] = time();
// Expire old tokens
while (reset($this->requests[$id]) < time() - 60) {
array_shift($this->requests[$id]);
}
if (count($this->requests[$id]) > $this->options['requests_per_minute']) {
$this->limit($connection, 'Requests per minute');
}
}
示例4: addConnection
public function addConnection(Connection $connection)
{
$this->connections[$connection->getId()] = $connection;
}
示例5: remove
public function remove(Connection $connection)
{
unset($this->connections[$connection->getId()]);
}