-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #266 from d47081/ratchet-ws
draft ratchet/ws server #261
- Loading branch information
Showing
2 changed files
with
42 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
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,37 @@ | ||
<?php | ||
|
||
namespace ChessServer\Cli\Ratchet; | ||
|
||
use ChessServer\Socket\RatchetClientStorage; | ||
use ChessServer\Socket\RatchetWebSocket; | ||
use Dotenv\Dotenv; | ||
use Monolog\Logger; | ||
use Monolog\Handler\StreamHandler; | ||
use Ratchet\Http\HttpServer; | ||
use Ratchet\Http\OriginCheck; | ||
use Ratchet\Server\IoServer; | ||
use Ratchet\WebSocket\WsServer; | ||
|
||
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); | ||
|
||
$webSocket = (new RatchetWebSocket())->init($clientStorage); | ||
|
||
$ioServer = IoServer::factory( | ||
new HttpServer( | ||
new WsServer( | ||
$webSocket | ||
) | ||
), | ||
$_ENV['WS_PORT'], | ||
$_ENV['WS_ADDRESS'] | ||
); | ||
|
||
$ioServer->run(); |