sonar fix
continuous-integration/drone/push Build is failing Details

This commit is contained in:
Pavel Dmitriev 2023-01-22 11:32:29 +03:00
parent 8fb0336a3c
commit b4ec5c915b
1 changed files with 12 additions and 12 deletions

View File

@ -22,16 +22,16 @@ $connection=null;
$channel=null; $channel=null;
while(1) { while (1) {
try { try {
$connection=rabbitConnect($rabbitHost,$rabbitPort,$rabbitLogin,$rabbitPass,$rabbitUseSSL); $connection=rabbitConnect($rabbitHost, $rabbitPort, $rabbitLogin, $rabbitPass, $rabbitUseSSL);
$channel=$connection->channel(); $channel=$connection->channel();
scanner($channel,$port); scanner($channel, $port);
} catch (Exception $e) { } catch (Exception $e) {
print "Exception ".$e->getMessage()."\n"; print "Exception ".$e->getMessage()."\n";
$channel->close(); $channel->close();
$connection->close(); $connection->close();
$s=rand(5,15); $s=rand(5, 15);
print "Sleep $s seconds.."; print "Sleep $s seconds..";
sleep($s); sleep($s);
print "Ok\n"; print "Ok\n";
@ -47,9 +47,9 @@ function rabbitConnect($rabbitHost, $rabbitPort, $rabbitLogin, $rabbitPass, $rab
'allow_self_signed' => false 'allow_self_signed' => false
]; ];
$connection = new AMQPSSLConnection($rabbitHost, $rabbitPort, $rabbitLogin, $rabbitPass,$rabbitVirtualHost,$ssl_opts); $connection = new AMQPSSLConnection($rabbitHost, $rabbitPort, $rabbitLogin, $rabbitPass, $rabbitVirtualHost, $ssl_opts);
} else { } else {
$connection = new AMQPStreamConnection($rabbitHost, $rabbitPort, $rabbitLogin, $rabbitPass,$rabbitVirtualHost); $connection = new AMQPStreamConnection($rabbitHost, $rabbitPort, $rabbitLogin, $rabbitPass, $rabbitVirtualHost);
} }
return $connection; return $connection;
} }
@ -68,9 +68,9 @@ function scanner($channel, $port) {
} }
} }
while(1) { while (1) {
$buffer = fgets($fp,4096); $buffer = fgets($fp, 4096);
$rv=explode("\n",$buffer); $rv=explode("\n", $buffer);
if ($buffer === false) { if ($buffer === false) {
if (!empty($routingTag)) { if (!empty($routingTag)) {
$msg = new AMQPMessage(json_encode(["type"=>"service","data"=>"scannerFailed"])); $msg = new AMQPMessage(json_encode(["type"=>"service","data"=>"scannerFailed"]));
@ -79,7 +79,7 @@ function scanner($channel, $port) {
throw new Exception("Stream read failed. Scanner disconnected?"); throw new Exception("Stream read failed. Scanner disconnected?");
} }
if (preg_match('/^fxc([0-9a-f]{20})xf$/',$buffer,$ref)) { if (preg_match('/^fxc([0-9a-f]{20})xf$/', $buffer, $ref)) {
print "Pairing request. Routing tag: $ref[1]\n"; print "Pairing request. Routing tag: $ref[1]\n";
$routingTag=$ref[1]; $routingTag=$ref[1];
$msg = new AMQPMessage(json_encode(["type"=>"service","data"=>"scannerRegistered"])); $msg = new AMQPMessage(json_encode(["type"=>"service","data"=>"scannerRegistered"]));