Could you please tell me how to call the following heartbeat monitoring code? Thanks!
悬崖上的草
悬崖上的草 2021-03-31 08:09:00
0
1
1262

The following is the heartbeat monitoring code snippet of the web server background that keeps it running at all times through the "php XXX.php" command. How do I display $A in try on the front-end browser? Thanks!

while (true) {

if ($stomp == null || !$stomp->getClient()->isConnected()) {

echo "connection not exists, will reconnect after 10s.", PHP_EOL;

sleep(10);

$stomp = start_consume();

}

## Try {

Business logic.

$A = $stomp->read();

echo "start consumer:";

echo "<br/>";

// echo $A;

$arr = explode(':',$A);

// echo "<br/>";

// $B = json_decode($A,true);

$arr1 = ($arr[16]);

// var_dump ($arr1[0]);

echo "<br/>";

$B = json_encode($arr1,true);

echo $B;

// $B1 = json_decode($B,true);

echo "<br/>";

}

catch(HeartbeatException $e) {

echo 'The server failed to send us heartbeats within the defined interval.', PHP_EOL;

$stomp->getClient()->disconnect();

} catch (Exception $e) {

echo 'process message occurs error '. $e->getMessage() , PHP_EOL;

}

悬崖上的草
悬崖上的草

reply all(1)
欧阳

Yours is PHP code, heartbeat monitoring. You use the front-end to always request this method. When $A is passed to the front-end, you pass it how you pass the value to the front-end.

Generally, the front end uses ajax to request php, and php uses echo json_encode to return to ajax

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template