From 68fd9998329e2b7d82c2847931f8173b58b29b17 Mon Sep 17 00:00:00 2001 From: azammitdcarf Date: Thu, 29 Jul 2010 02:22:37 +0000 Subject: [PATCH] Set VoipWatch to auto reconnect when disconnected Will not automatically refresh Voip Watch page (can just click on link to reload) --- admin/voipmonitor.php | 2 +- functions/functions.voip.php | 17 +++++++++++++---- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/admin/voipmonitor.php b/admin/voipmonitor.php index cf9603f0..fdc935c9 100644 --- a/admin/voipmonitor.php +++ b/admin/voipmonitor.php @@ -70,7 +70,7 @@ if ($p) kill_process($p); } - xhtml_head(T_("Monitor VoIP Process"),true,false,false,false,10,true); + xhtml_head(T_("Monitor VoIP Process"),true,false,false,false,false,true); print "

" . T_("Running process:") . " $p

"; diff --git a/functions/functions.voip.php b/functions/functions.voip.php index d233e390..c1c6e68f 100644 --- a/functions/functions.voip.php +++ b/functions/functions.voip.php @@ -52,8 +52,11 @@ class voip { */ function __destruct() { //close the socket - fclose($this->socket); - $this->socket = false; + if ($this->socket !== false) + { + fclose($this->socket); + $this->socket = false; + } } @@ -318,8 +321,8 @@ class voip { $this->socket = fsockopen($ip,VOIP_PORT,$errno,$errstr,1); if (!$this->socket) { - print "$errno: $errstr"; - exit(); + //print "$errno: $errstr"; + //exit(); return false; } @@ -465,6 +468,12 @@ class voipWatch extends voip { do { + if (!$this->isConnected() || $this->socket === false){ + print(T_("Disconnected") . "\n"); + $this->connect(VOIP_SERVER,VOIP_ADMIN_USER,VOIP_ADMIN_PASS,true); + if ($this->isConnected()) print (T_("Reconnected") . "\n"); + } + $in = fgets($this->socket, 4096); //print "IN: $in\n";