Skip to content

Commit

Permalink
Added http only server.
Browse files Browse the repository at this point in the history
  • Loading branch information
lotharthesavior committed Apr 24, 2024
1 parent 55933be commit 05f9761
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 9 deletions.
2 changes: 1 addition & 1 deletion config/jacked-server.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
// ------------------------------------------------------------

'websocket' => [
'enabled' => env('JACKED_SERVER_WEBSOCKET_ENABLED', true),
'enabled' => env('JACKED_SERVER_WEBSOCKET_ENABLED', false),
'broadcaster' => false,
],

Expand Down
14 changes: 6 additions & 8 deletions src/Services/Server.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,14 +96,6 @@ public function run(): void
$host = $this->host ?? config('jacked-server.host', '0.0.0.0');
$primaryPort = $ssl ? config('jacked-server.ssl-port', 443) : config('jacked-server.port', 8080);

if (false === config('jacked-server.websocket.enabled', true)) {
// TODO: craft HTTP only server
throw new Exception(
'WebSockets are not enabled! HTTP only servers are not ' .
'available yet by Jacked Server.',
);
}

$this->wsPersistence = array_merge(
Conveyor::defaultPersistence(),
$this->wsPersistence,
Expand Down Expand Up @@ -138,6 +130,12 @@ public function run(): void

public function handleWsHandshake(Request $request, Response $response): bool
{
if (false === config('jacked-server.websocket.enabled', true)) {
$response->status(401);
$response->end('WebSocket Not enabled!');
return false;
}

$this->logger->info($this->logPrefix . ' Handshake received from ' . $request->fd);

// evaluate intention to upgrade to websocket
Expand Down

0 comments on commit 05f9761

Please sign in to comment.