-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c5b10a3
commit ac8ca11
Showing
3 changed files
with
81 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
<?php | ||
|
||
namespace ChessServer\Cli\Ratchet; | ||
|
||
use ChessServer\Command\CommandParser; | ||
use ChessServer\Command\Data\CommandContainer; | ||
use ChessServer\Socket\RatchetClientStorage; | ||
use ChessServer\Socket\RatchetWebSocket; | ||
use Dotenv\Dotenv; | ||
use Monolog\Logger; | ||
use Monolog\Handler\StreamHandler; | ||
use Ratchet\Http\HttpServer; | ||
use Ratchet\Server\IoServer; | ||
use Ratchet\WebSocket\WsServer; | ||
use React\EventLoop\Factory; | ||
use React\Socket\LimitingServer; | ||
use React\Socket\Server; | ||
use React\Socket\SecureServer; | ||
|
||
require __DIR__ . '/../../vendor/autoload.php'; | ||
|
||
$dotenv = Dotenv::createImmutable(__DIR__.'/../../'); | ||
$dotenv->load(); | ||
|
||
$logger = new Logger('log'); | ||
$logger->pushHandler(new StreamHandler(__DIR__.'/../../storage' . '/pchess.log', Logger::INFO)); | ||
|
||
$clientStorage = new RatchetClientStorage($logger); | ||
|
||
$parser = new CommandParser(new CommandContainer()); | ||
|
||
$webSocket = (new RatchetWebSocket($parser))->init($clientStorage); | ||
|
||
$loop = Factory::create(); | ||
|
||
$server = new Server("{$_ENV['WSS_ADDRESS']}:{$_ENV['WSS_DATA_PORT']}", $loop); | ||
|
||
$secureServer = new SecureServer($server, $loop, [ | ||
'local_cert' => __DIR__ . '/../../ssl/fullchain.pem', | ||
'local_pk' => __DIR__ . '/../../ssl/privkey.pem', | ||
'verify_peer' => false, | ||
]); | ||
|
||
$limitingServer = new LimitingServer($secureServer, 50); | ||
|
||
$httpServer = new HttpServer(new WsServer($webSocket)); | ||
|
||
$ioServer = new IoServer($httpServer, $limitingServer, $loop); | ||
|
||
$ioServer->run(); |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
services: | ||
chess_server_game: | ||
build: | ||
context: . | ||
dockerfile: Dockerfile | ||
user: 1000:1000 | ||
container_name: chess_server_game | ||
ports: | ||
- ${WSS_GAME_PORT}:${WSS_GAME_PORT} | ||
restart: always | ||
volumes: | ||
- ./:/usr/share/chess-server | ||
- /usr/share/chess-server/vendor | ||
- ./docker/php/8.2/cli/php.ini:/usr/local/etc/php/php.ini | ||
working_dir: /usr/share/chess-server | ||
command: ["php", "cli/ratchet/game.php"] | ||
chess_server_data: | ||
build: | ||
context: . | ||
dockerfile: Dockerfile | ||
user: 1000:1000 | ||
container_name: chess_server_data | ||
ports: | ||
- ${WSS_DATA_PORT}:${WSS_DATA_PORT} | ||
restart: always | ||
volumes: | ||
- ./:/usr/share/chess-server | ||
- /usr/share/chess-server/vendor | ||
- ./docker/php/8.2/cli/php.ini:/usr/local/etc/php/php.ini | ||
working_dir: /usr/share/chess-server | ||
command: ["php", "cli/ratchet/data.php"] |