wip
This commit is contained in:
parent
f9d44040eb
commit
c6c65fde8a
|
|
@ -0,0 +1,30 @@
|
|||
<?php
|
||||
|
||||
return [
|
||||
|
||||
/*
|
||||
* Define the optional SSL context for your websocket connections.
|
||||
* You can see all available options at: http://php.net/manual/en/context.ssl.php
|
||||
*/
|
||||
'ssl' => [
|
||||
/*
|
||||
* Path to local certificate file on filesystem. It must be a PEM encoded file which
|
||||
* contains your certificate and private key. It can optionally contain the
|
||||
* certificate chain of issuers. The private key also may be contained
|
||||
* in a separate file specified by local_pk.
|
||||
*/
|
||||
'local_cert' => null,
|
||||
|
||||
/*
|
||||
* Path to local private key file on filesystem in case of separate files for
|
||||
* certificate (local_cert) and private key.
|
||||
*/
|
||||
'local_pk' => null,
|
||||
|
||||
/*
|
||||
* Passphrase with which your local_cert file was encoded.
|
||||
*/
|
||||
'passphrase' => null
|
||||
],
|
||||
|
||||
];
|
||||
|
|
@ -9,6 +9,10 @@ class LaravelWebSocketsServiceProvider extends ServiceProvider
|
|||
{
|
||||
public function boot()
|
||||
{
|
||||
$this->publishes([
|
||||
__DIR__.'/../config/config.php' => base_path('config/websockets.php'),
|
||||
], 'config');
|
||||
|
||||
$this->commands([
|
||||
Console\StartWebSocketServer::class,
|
||||
]);
|
||||
|
|
@ -16,6 +20,8 @@ class LaravelWebSocketsServiceProvider extends ServiceProvider
|
|||
|
||||
public function register()
|
||||
{
|
||||
$this->mergeConfigFrom(__DIR__.'/../config/config.php', 'websockets');
|
||||
|
||||
$this->app->singleton('websockets.router', function() {
|
||||
return new Router();
|
||||
});
|
||||
|
|
|
|||
|
|
@ -3,10 +3,11 @@
|
|||
namespace BeyondCode\LaravelWebSockets\Server;
|
||||
|
||||
use Ratchet\Http\Router;
|
||||
use React\Socket\SecureServer;
|
||||
use React\Socket\Server;
|
||||
use Ratchet\Http\HttpServer;
|
||||
use Ratchet\Server\IoServer;
|
||||
use React\EventLoop\LoopInterface;
|
||||
use React\Socket\Server as Reactor;
|
||||
use React\EventLoop\Factory as LoopFactory;
|
||||
use Symfony\Component\Routing\RequestContext;
|
||||
use Symfony\Component\Routing\Matcher\UrlMatcher;
|
||||
|
|
@ -63,7 +64,11 @@ class WebSocketServer
|
|||
|
||||
protected function createServer(): IoServer
|
||||
{
|
||||
$socket = new Reactor("{$this->host}:{$this->port}", $this->loop);
|
||||
$socket = new Server("{$this->host}:{$this->port}", $this->loop);
|
||||
|
||||
if (config('websockets.ssl.local_cert')) {
|
||||
$socket = new SecureServer($socket, $this->loop, config('websockets.ssl'));
|
||||
}
|
||||
|
||||
$urlMatcher = new UrlMatcher($this->routes, new RequestContext);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue