This commit is contained in:
Marcel Pociot 2018-11-27 21:07:21 +01:00
parent 15aa70d7c9
commit 8f13738d95
3 changed files with 4 additions and 31 deletions

View File

@ -2,14 +2,14 @@
namespace BeyondCode\LaravelWebSockets\Exceptions;
use BeyondCode\LaravelWebSockets\Server\WebSocketController;
use Ratchet\WebSocket\MessageComponentInterface;
class InvalidWebSocketController extends \Exception
{
public static function withController(string $controllerClass)
{
$websocketControllerClass = WebSocketController::class;
$messageComponentInterfaceClass = MessageComponentInterface::class;
return new static("Invalid WebSocket Controller provided. Expected instance of `{$websocketControllerClass}`, but received `{$controllerClass}`.");
return new static("Invalid WebSocket Controller provided. Expected instance of `{$messageComponentInterfaceClass}`, but received `{$controllerClass}`.");
}
}

View File

@ -27,7 +27,7 @@ class Router
public function websocket(string $uri, $action)
{
if (!is_subclass_of($action, WebSocketController::class)) {
if (!is_subclass_of($action, MessageComponentInterface::class)) {
throw InvalidWebSocketController::withController($action);
}

View File

@ -1,27 +0,0 @@
<?php
namespace BeyondCode\LaravelWebSockets\Server;
use Exception;
use Ratchet\ConnectionInterface;
use Ratchet\RFC6455\Messaging\MessageInterface;
use Ratchet\WebSocket\MessageComponentInterface;
class WebSocketController implements MessageComponentInterface
{
function onOpen(ConnectionInterface $connection)
{
}
public function onMessage(ConnectionInterface $connection, MessageInterface $message)
{
}
function onClose(ConnectionInterface $connection)
{
}
function onError(ConnectionInterface $connection, Exception $exception)
{
}
}