41 lines
832 B
PHP
41 lines
832 B
PHP
<?php
|
|
|
|
namespace app\net;
|
|
|
|
use Workerman\Connection\TcpConnection;
|
|
|
|
class PacketContext
|
|
{
|
|
public $connections {
|
|
get => $this->connections;
|
|
}
|
|
public TcpConnection $connection {
|
|
get => $this->connection;
|
|
}
|
|
public Packet $packet {
|
|
get => $this->packet;
|
|
}
|
|
|
|
public string $ip {
|
|
get => $this->connection->getRemoteIp();
|
|
}
|
|
|
|
public int $port {
|
|
get => $this->connection->getRemotePort();
|
|
}
|
|
/**
|
|
* @var int 上下文创建时的时间
|
|
*/
|
|
public int $createTime {
|
|
get {
|
|
return time();
|
|
}
|
|
}
|
|
|
|
public function __construct(array $connections,TcpConnection $connection, Packet $packet)
|
|
{
|
|
$this->connections = $connections;
|
|
$this->connection = $connection;
|
|
$this->packet = $packet;
|
|
}
|
|
} |