Optimized

This commit is contained in:
huangzhhui 2020-06-18 23:18:27 +08:00
parent e66bfef473
commit 9d897a656a
2 changed files with 4 additions and 1 deletions

View File

@ -47,6 +47,9 @@ class JsonLengthPacker implements PackerInterface
public function unpack(string $data)
{
$data = substr($data, $this->length);
if (! $data) {
return null;
}
return json_decode($data, true);
}
}

View File

@ -31,7 +31,7 @@ trait RecvTrait
throw new RecvException('Connection is closed.');
}
if ($data === false) {
throw new RecvException('Error receiving data, errno=' . $client->errCode);
throw new RecvException('Error receiving data, errno=' . $client->errCode . ' errmsg=' . swoole_strerror($client->errCode));
}
return $data;