File tree Expand file tree Collapse file tree 3 files changed +43
-2
lines changed Expand file tree Collapse file tree 3 files changed +43
-2
lines changed Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ return [
4
+
5
+ /*
6
+ * Define the optional SSL context for your websocket connections.
7
+ * You can see all available options at: http://php.net/manual/en/context.ssl.php
8
+ */
9
+ 'ssl ' => [
10
+ /*
11
+ * Path to local certificate file on filesystem. It must be a PEM encoded file which
12
+ * contains your certificate and private key. It can optionally contain the
13
+ * certificate chain of issuers. The private key also may be contained
14
+ * in a separate file specified by local_pk.
15
+ */
16
+ 'local_cert ' => null ,
17
+
18
+ /*
19
+ * Path to local private key file on filesystem in case of separate files for
20
+ * certificate (local_cert) and private key.
21
+ */
22
+ 'local_pk ' => null ,
23
+
24
+ /*
25
+ * Passphrase with which your local_cert file was encoded.
26
+ */
27
+ 'passphrase ' => null
28
+ ],
29
+
30
+ ];
Original file line number Diff line number Diff line change @@ -9,13 +9,19 @@ class LaravelWebSocketsServiceProvider extends ServiceProvider
9
9
{
10
10
public function boot ()
11
11
{
12
+ $ this ->publishes ([
13
+ __DIR__ .'/../config/config.php ' => base_path ('config/websockets.php ' ),
14
+ ], 'config ' );
15
+
12
16
$ this ->commands ([
13
17
Console \StartWebSocketServer::class,
14
18
]);
15
19
}
16
20
17
21
public function register ()
18
22
{
23
+ $ this ->mergeConfigFrom (__DIR__ .'/../config/config.php ' , 'websockets ' );
24
+
19
25
$ this ->app ->singleton ('websockets.router ' , function () {
20
26
return new Router ();
21
27
});
Original file line number Diff line number Diff line change 3
3
namespace BeyondCode \LaravelWebSockets \Server ;
4
4
5
5
use Ratchet \Http \Router ;
6
+ use React \Socket \SecureServer ;
7
+ use React \Socket \Server ;
6
8
use Ratchet \Http \HttpServer ;
7
9
use Ratchet \Server \IoServer ;
8
10
use React \EventLoop \LoopInterface ;
9
- use React \Socket \Server as Reactor ;
10
11
use React \EventLoop \Factory as LoopFactory ;
11
12
use Symfony \Component \Routing \RequestContext ;
12
13
use Symfony \Component \Routing \Matcher \UrlMatcher ;
@@ -63,7 +64,11 @@ public function run()
63
64
64
65
protected function createServer (): IoServer
65
66
{
66
- $ socket = new Reactor ("{$ this ->host }: {$ this ->port }" , $ this ->loop );
67
+ $ socket = new Server ("{$ this ->host }: {$ this ->port }" , $ this ->loop );
68
+
69
+ if (config ('websockets.ssl.local_cert ' )) {
70
+ $ socket = new SecureServer ($ socket , $ this ->loop , config ('websockets.ssl ' ));
71
+ }
67
72
68
73
$ urlMatcher = new UrlMatcher ($ this ->routes , new RequestContext );
69
74
You can’t perform that action at this time.
0 commit comments