Browse Source

ADD: debug level >2 in AsyncCallAPI for open/close socket

Giancarlo Voci 7 years ago
parent
commit
006214d50c
2 changed files with 22 additions and 12 deletions
  1. 14 12
      src/Modules/Blank/Pages.php
  2. 8 0
      src/OpenMind/FindBox/FindBoxCoreSystem.php

+ 14 - 12
src/Modules/Blank/Pages.php

@@ -58,27 +58,29 @@ class Pages extends Controller
 					//$findBoxCore->UnBind($label);
 				}*/
 
-/*		$this->BlinkOFF($labels);
-		sleep(5);
+		/*	foreach($labels as $label) {
+				$this->BlinkONW([$label]);
+			}*/
 
-		$this->BlinkON($labels);*/
+/*
+		foreach($labels as $i => $label) {
+			if ($i > 10)
+				break;
+			$this->BlinkOFF([$label]);
+		}*/
 
-		$this->BlinkONW([
-			'0113067F',
-			'011306C5',
-			'01130713',
-			'01130747']);
+		$this->BlinkOFF($labels);
 
 		$f3->set('MESSAGE', 'Hello World');
 		$f3->set('CONTENT', 'message.tpl');
 		echo Template::instance()->render('masterpage.tpl');
 	}
 
-	public function BlinkON(array $labels)
+	public function BlinkOFF(array $labels)
 	{
 		$qs = new QueueSystem();
 		$cmd = new QueueCommand($labels);
-		$cmd->setLeds(2, 1, 1000, 300, 1);
+		$cmd->setToBlinkOff();
 		$qs->send($cmd);
 	}
 
@@ -90,11 +92,11 @@ class Pages extends Controller
 		$qs->send($cmd);
 	}
 
-	public function BlinkOFF(array $labels)
+	public function BlinkON(array $labels)
 	{
 		$qs = new QueueSystem();
 		$cmd = new QueueCommand($labels);
-		$cmd->setToBlinkOff();
+		$cmd->setLeds(2, 1, 1000, 300, 1);
 		$qs->send($cmd);
 	}
 }

+ 8 - 0
src/OpenMind/FindBox/FindBoxCoreSystem.php

@@ -120,9 +120,14 @@ class FindBoxCoreSystem
 	 */
 	public function AsyncCallAPI(string $URI, string $Parameters, bool $skipResponse = false): Generator
 	{
+		global $f3, $frameworkUtils;
+
 		$bodyJSON = null;
 		$auth = "Authorization: Basic " . base64_encode("{$this->Key}:{$this->Pass}") . "\r\n";
 
+		if ($f3->get('DEBUG') > 2)
+			$frameworkUtils->getLogger()->write("AsyncCallAPI::OpenSocket: $Parameters", 'd/m/Y H:i:s');
+
 		$streamfbOS = @stream_socket_client("tcp://{$this->Host}:{$this->Port}", $errno, $errstr, 1);
 		if (!$streamfbOS) {
 			return $this->returnCode($errno, $errstr);
@@ -141,6 +146,9 @@ class FindBoxCoreSystem
 					}
 				list(, $bodyJSON) = explode("\r\n\r\n", $r, 2);
 			}
+			if ($f3->get('DEBUG') > 2)
+				$frameworkUtils->getLogger()->write("AsyncCallAPI::CloseSocket: $Parameters", 'd/m/Y H:i:s');
+
 			fclose($streamfbOS);
 		}