wip
This commit is contained in:
parent
fc622bc626
commit
efb603ea95
|
|
@ -1,12 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace BeyondCode\LaravelWebSockets\LaravelEcho\Pusher\Exceptions;
|
||||
|
||||
class UnknownAppId extends PusherException
|
||||
{
|
||||
public function __construct(string $appId)
|
||||
{
|
||||
$this->message = "Could not find app key {$appId}";
|
||||
$this->code = 4001;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
<?php
|
||||
|
||||
namespace BeyondCode\LaravelWebSockets\LaravelEcho\Pusher\Exceptions;
|
||||
|
||||
class UnknownAppKey extends PusherException
|
||||
{
|
||||
public function __construct(string $appKey)
|
||||
{
|
||||
$this->message = "Could not find app key {$appKey}";
|
||||
$this->code = 4001;
|
||||
}
|
||||
}
|
||||
|
|
@ -3,7 +3,7 @@
|
|||
namespace BeyondCode\LaravelWebSockets\LaravelEcho\WebSocket;
|
||||
|
||||
use BeyondCode\LaravelWebsockets\LaravelEcho\Pusher\Exceptions\PusherException;
|
||||
use BeyondCode\LaravelWebSockets\LaravelEcho\Pusher\Exceptions\UnknownAppId;
|
||||
use BeyondCode\LaravelWebSockets\LaravelEcho\Pusher\Exceptions\UnknownAppKey;
|
||||
use Exception;
|
||||
use Ratchet\ConnectionInterface;
|
||||
use Ratchet\RFC6455\Messaging\MessageInterface;
|
||||
|
|
@ -48,6 +48,7 @@ class PusherServer extends WebSocketController
|
|||
$exception->getPayload()
|
||||
));
|
||||
}
|
||||
dump($exception);
|
||||
}
|
||||
|
||||
protected function verifyConnection(ConnectionInterface $connection)
|
||||
|
|
@ -58,12 +59,12 @@ class PusherServer extends WebSocketController
|
|||
$queryParameters = [];
|
||||
parse_str($request->getUri()->getQuery(), $queryParameters);
|
||||
|
||||
$connection->appId = $queryParameters['appId'];
|
||||
|
||||
// Todo: Lookup app-id for multi-tenancy support
|
||||
if ($connection->appId !== config('broadcasting.connections.pusher.app_id')) {
|
||||
throw new UnknownAppId($connection->appId);
|
||||
if ($queryParameters['appKey'] !== config('broadcasting.connections.pusher.key')) {
|
||||
throw new UnknownAppKey($queryParameters['appKey']);
|
||||
}
|
||||
|
||||
$connection->appId = config('broadcasting.connections.pusher.app_id');
|
||||
}
|
||||
|
||||
protected function establishConnection(ConnectionInterface $connection)
|
||||
|
|
|
|||
|
|
@ -66,7 +66,7 @@ class Router
|
|||
public function echo()
|
||||
{
|
||||
//TODO: add origin checker middleware
|
||||
$this->get('/app/{appId}', LaravelEcho\WebSocket\PusherServer::class);
|
||||
$this->get('/app/{appKey}', LaravelEcho\WebSocket\PusherServer::class);
|
||||
|
||||
// TODO: fleshen out http API
|
||||
$this->get('/apps/{appId}/status', LaravelEcho\Http\Controllers\StatusController::class);
|
||||
|
|
|
|||
Loading…
Reference in New Issue