diff --git a/build/kwebsocket/core/wsinterop.php b/build/kwebsocket/core/wsinterop.php index 8867421..c3224ff 100644 --- a/build/kwebsocket/core/wsinterop.php +++ b/build/kwebsocket/core/wsinterop.php @@ -1,6 +1,6 @@ 0 ){ + + // get/send name to web socket + $wsi->send(['type' => 'user', 'name' => $_SESSION['USER']['username']]); + $check = $wsi->receive(); + + if( $check['error'] == false ) + $_SESSION['NAME'] = $check['name']; + + }elseif( count($_SESSION['ADMIN']) > 0 ){ + + // get/send name to web socket + $wsi->send(['type' => 'admin', 'name' => $_SESSION['ADMIN']['username']]); + $check = $wsi->receive(); + + if( $check['error'] == false ) + $_SESSION['NAME'] = $check['name']; + + }else{ + + // get/send name to web socket + $wsi->send(['type' => 'guest', 'name' => null]); + $check = $wsi->receive(); + + if( $check['error'] == false ) + $_SESSION['NAME'] = $check['name']; + } + + $wsi = null; + + } if( file_exists(__ROOT__."/view/home.php") ) include __ROOT__."/view/home.php"; else diff --git a/public_html/index.php b/public_html/index.php index 12ea6cf..c57fb65 100755 --- a/public_html/index.php +++ b/public_html/index.php @@ -5,46 +5,9 @@ use \api\core\Request; use \api\core\AuthSystemDefault; use \database\core\DatabaseDriver; - use \kwebsocket\core\wsinterop; /* (1) Start session */ session_start(); - if( !isset($_SESSION['NAME']) || strlen($_SESSION['NAME']) == 0 ){ - - // ask with websocketInterop - $wsi = new wsinterop('localhost', 9998); - - if( count($_SESSION['USER']) > 0 ){ - - // get/send name to web socket - $wsi->send(['type' => 'user', 'name' => $_SESSION['USER']['username']]); - $check = $wsi->receive(); - - if( $check['error'] == false ) - $_SESSION['NAME'] = $check['name']; - - }elseif( count($_SESSION['ADMIN']) > 0 ){ - - // get/send name to web socket - $wsi->send(['type' => 'admin', 'name' => $_SESSION['ADMIN']['username']]); - $check = $wsi->receive(); - - if( $check['error'] == false ) - $_SESSION['NAME'] = $check['name']; - - }else{ - - // get/send name to web socket - $wsi->send(['type' => 'guest', 'name' => null]); - $check = $wsi->receive(); - - if( $check['error'] == false ) - $_SESSION['NAME'] = $check['name']; - } - - $wsi = null; - - } /* (2) Set default Driver for Repos */ Repo::setDriver(DatabaseDriver::get());