改名
This commit is contained in:
+27
-1
@@ -8,6 +8,7 @@ use Exception;
|
|||||||
use HttpServer\IInterface\Task;
|
use HttpServer\IInterface\Task;
|
||||||
use ReflectionException;
|
use ReflectionException;
|
||||||
use Snowflake\Abstracts\Config;
|
use Snowflake\Abstracts\Config;
|
||||||
|
use Snowflake\Core\JSON;
|
||||||
use Snowflake\Di\Container;
|
use Snowflake\Di\Container;
|
||||||
use Snowflake\Exception\NotFindClassException;
|
use Snowflake\Exception\NotFindClassException;
|
||||||
use Snowflake\Process\Process;
|
use Snowflake\Process\Process;
|
||||||
@@ -191,8 +192,14 @@ class Snowflake
|
|||||||
return $object;
|
return $object;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $worker_pid
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
public static function clearProcessId($worker_pid)
|
public static function clearProcessId($worker_pid)
|
||||||
{
|
{
|
||||||
|
@unlink(storage("{$worker_pid}.sock",'worker'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -202,7 +209,7 @@ class Snowflake
|
|||||||
*/
|
*/
|
||||||
public static function getWebSocket()
|
public static function getWebSocket()
|
||||||
{
|
{
|
||||||
$server = static::app()->get('server')->getServer();
|
$server = static::app()->server->getServer();
|
||||||
if (!($server instanceof Server)) {
|
if (!($server instanceof Server)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@@ -210,6 +217,25 @@ class Snowflake
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param int $fd
|
||||||
|
* @param $data
|
||||||
|
* @return false|mixed
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
public static function push(int $fd, $data)
|
||||||
|
{
|
||||||
|
$server = static::getWebSocket();
|
||||||
|
if (empty($server)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (!is_string($data)) {
|
||||||
|
$data = JSON::encode($data);
|
||||||
|
}
|
||||||
|
return $server->push($fd, $data);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string $class
|
* @param string $class
|
||||||
* @param array $params
|
* @param array $params
|
||||||
|
|||||||
Reference in New Issue
Block a user