Ejemplo n.º 1
0
 /**
  * Disconnect a socket connection when required, resource could be temp or verified
  * @param $resSocket
  * @param string $strErrorMessage
  * @param bool $blRebootAlert
  */
 protected function disconnect($resSocket, $strErrorMessage = "Unknown Reason for disconnect", $blRebootAlert = false)
 {
     if ($blRebootAlert == true) {
         $arrRebootData = array('instance' => '', 'system' => 'twist', 'action' => 'restart', 'message' => $strErrorMessage, 'data' => array('time' => 60 - date('s') + 5));
         Sockets::writeJSON($resSocket, $arrRebootData);
     }
     //Remove the socket from the list of connected sockets
     if (Sockets::isTemporary($resSocket)) {
         Sockets::removeTemporary($resSocket);
     } else {
         Sockets::remove($resSocket);
     }
     System::stats();
     System::log(sprintf("Disconnected from server: %s", $strErrorMessage));
 }