Esempio n. 1
0
 /**
  * Process events on the master socket ($this->socket)
  *
  * @return void
  */
 protected function processMasterSocket()
 {
     $new = null;
     try {
         $new = $this->socket->accept();
     } catch (Exception $e) {
         $this->server->log('Socket error: ' . $e, 'err');
         return;
     }
     $connection = $this->createConnection($new);
     $this->server->notify(Server::EVENT_SOCKET_CONNECT, array($new, $connection));
 }
Esempio n. 2
0
 /**
  * Deactivate the listener
  * @since 0.9
  */
 public function Deactivate()
 {
     $this->socket->Close();
     $this->active = false;
 }
Esempio n. 3
0
                } else {
                    echo json_encode(array("error" => true, "data" => "Accesso no permitido"));
                }
            } else {
                $this->resolveService($service, $params, $conn);
            }
        } else {
            echo json_encode(array("error" => true, "data" => "Servicio no disponible"));
        }
    }
    protected function connected($conn)
    {
        //Recogemos token de sesión
        // Do nothing: This is just an echo server, there's no need to track the user.
        // However, if we did care about the users, we would probably have a cookie to
        // parse at this step, would be looking them up in permanent storage, etc.
    }
    protected function closed($conn)
    {
        //echo $this->clients->count();
        // Do nothing: This is where cleanup would go, in case the user had any sort of
        // open files or other objects associated with them.  This runs after the socket
        // has been closed, so there is no need to clean up the socket itself here.
    }
}
$ss = new ServerSocket("127.0.0.1", "30000");
try {
    $ss->run();
} catch (Exception $e) {
    $ss->stdout($e->getMessage());
}