改名
This commit is contained in:
@@ -43,14 +43,10 @@ class OnPacket extends Callback
|
|||||||
if (empty($data)) {
|
if (empty($data)) {
|
||||||
throw new Exception('Format error.');
|
throw new Exception('Format error.');
|
||||||
}
|
}
|
||||||
$client = DataResolve::pack($this->pack, $data);
|
return $server->sendto($clientInfo['address'], $clientInfo['port'], DataResolve::pack($this->pack, $data));
|
||||||
return $server->sendto($clientInfo['address'], $clientInfo['port'], $client ?? 'Format error');
|
|
||||||
} catch (\Throwable $exception) {
|
} catch (\Throwable $exception) {
|
||||||
$client = DataResolve::pack($this->pack, $exception->getMessage());
|
$pack = DataResolve::pack($this->pack, ['message' => $exception->getMessage()]);
|
||||||
|
return $server->sendto($clientInfo['address'], $clientInfo['port'], $pack);
|
||||||
var_dump($exception->getMessage());
|
|
||||||
|
|
||||||
return $server->sendto($clientInfo['address'], $clientInfo['port'], $client ?? 'Format error');
|
|
||||||
} finally {
|
} finally {
|
||||||
$event = Snowflake::app()->event;
|
$event = Snowflake::app()->event;
|
||||||
$event->trigger(Event::SERVER_WORKER_STOP);
|
$event->trigger(Event::SERVER_WORKER_STOP);
|
||||||
|
|||||||
@@ -26,9 +26,14 @@ class DataResolve
|
|||||||
public static function pack($unpack, $data)
|
public static function pack($unpack, $data)
|
||||||
{
|
{
|
||||||
if (empty($unpack)) {
|
if (empty($unpack)) {
|
||||||
return JSON::encode($data);
|
$params = JSON::encode($data);
|
||||||
|
} else {
|
||||||
|
$params = self::callbackResolve($unpack, null, null, $data);
|
||||||
}
|
}
|
||||||
return self::callbackResolve($unpack, null, null, $data);
|
if ($params === null) {
|
||||||
|
return 'Format error.';
|
||||||
|
}
|
||||||
|
return $params;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -44,9 +49,14 @@ class DataResolve
|
|||||||
public static function unpack($unpack, $address, $port, $data)
|
public static function unpack($unpack, $address, $port, $data)
|
||||||
{
|
{
|
||||||
if (empty($unpack)) {
|
if (empty($unpack)) {
|
||||||
return JSON::decode($data);
|
$params = JSON::decode($data);
|
||||||
|
} else {
|
||||||
|
$params = self::callbackResolve($unpack, $address, $port, $data);
|
||||||
}
|
}
|
||||||
return self::callbackResolve($unpack, $address, $port, $data);
|
if ($params === null) {
|
||||||
|
return 'Format error.';
|
||||||
|
}
|
||||||
|
return $params;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user