public function sendPacket($packet = null)
{
if ($this->conn && $this->conn->isConnected()) {
$this->conn->sendPacket($packet);
return;
}
$cb = function ($conn) use($packet) {
$conn->sendPacket($packet);
};
if (!$this->conn) {
$this->conn = new WorkerConnection(null, null, null);
$this->conn->connect($this->socketurl);
}
$this->conn->onConnected($cb);
}