public function procesarComandos($cmd) { if (strcmp($cmd->getAccion(), "COMPROBAR") == 0) { $this->comprobarSistema(1); SocketClass::client_reply("BUTTON:COMPROBAR:RELEASE:_level0.comprobar"); } else { if (strcmp($cmd->getAccion(), "INICIAR") == 0) { $this->sistema->iniciarSistema(); $this->comprobarProyectores(); //$this->comprobarSistema(); } else { if (strcmp($cmd->getAccion(), "APAGAR") == 0) { $this->sistema->salir(); } else { if (strcmp($cmd->getAccion(), "ESTADO") == 0) { $this->enviarPantallaActiva(); //$this->comprobarSistema(); // AccesoGui::$guiSistema->bienvenidaSistema(); // AccesoGui::$guiSistema->dibujarPantalla(); } else { if (strcmp($cmd->getAccion(), "LOGCLIENTES") == 0) { pnlControl . logClientList(); } } } } } }
/** * * * @param string comando * @return * @access public */ public function enviarPeticion($comando) { SocketClass::client_reply($comando->getComando()); }
function server_socket() { //---- Start Socket creation for PHP Socket Server ------------------------------------- system_class::log_message("socket server hasi"); if (($master = socket_create(AF_INET, SOCK_STREAM, SOL_TCP)) < 0) { system_class::log_message("socket_create() failed, reason: " . socket_strerror($master)); } $this->master_socket = $master; system_class::log_message("create_socket"); socket_set_option($master, SOL_SOCKET, SO_REUSEADDR, 1); if (($ret = socket_bind($master, ADDRESS, PORT)) < 0) { system_class::log_message("socket_bind() failed, reason: " . socket_strerror($ret)); } system_class::log_message("create_bind"); if (($ret = socket_listen($master, 5)) < 0) { system_class::log_message("socket_listen() failed, reason: " . socket_strerror($ret)); } system_class::log_message("listen"); self::$read_sockets = array($master); system_class::log_message("master:: " . print_r($master, 1)); //---- Create Persistent Loop to continuously handle incoming socket messages --------------------- while (true) { $changed_sockets = self::$read_sockets; $num_changed_sockets = socket_select($changed_sockets, $write = NULL, $except = NULL, NULL); system_class::log_message("IREKIAK:" . join(self::$read_sockets, ',') . " ALDATUAK:" . join($changed_sockets, ',') . "({$num_changed_sockets})"); if ($num_changed_sockets === false) { system_class::log_message("-------->ERROREA SOCKET-EAN<--------------"); } if (empty(self::$read_sockets)) { system_class::log_message("SOCKETA HUTSIK DAGO"); exit; } foreach ($changed_sockets as $socket) { $this->changed_socket = $socket; if ($socket == $master) { //flash konexio berria if (($client = socket_accept($master)) < 0) { system_class::log_message("socket_accept() failed: reason: " . socket_strerror($msgsock)); continue; } else { array_push(self::$read_sockets, $client); array_push(self::$flash_sockets, $client); self::$last_client = $client; } } else { //flash-etik idazten dute $bytes = socket_recv($socket, $buffer, 4096, 0); if (trim($bytes) == 0) { $this->quit_socket($socket); continue; } if ($buffer == 'bye') { $this->quit_socket($socket); continue; } else { system_class::log_message("\n\n @@@jaso cmd berria====>" . trim($buffer) . "<=====\n"); $arr_buf = explode('>', $buffer); foreach ($arr_buf as $buf) { $buf = trim($buf); if (!empty($buf)) { $buf = $buf . '>'; system_class::log_message("FLASH CMD: " . trim($buf)); $this->flash_cmd($socket, $buf); } } } } } } }
/** * Metodo para desmutear el proyector de la pizarra * * @access public */ public function activarPizarra() { $respuesta = self::$pizarra->desmutear(); $cmd2 = new ComandoFlash("PIZARRA_DIGITAL", "NO_MUTE"); $bb = $cmd2->getComando(); SocketClass::client_reply($bb); /*if(!empty ($respuesta)) { if(strcmp($respuesta,"?")==0) { echo "ERROR al enviar el comando ".$comando." al proyector de la pizarra, para activarla\n"; return 1; } else return 0; }else return 1;*/ }