feat: 实现TCP Server
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
<?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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user