wip
This commit is contained in:
parent
15aa70d7c9
commit
8f13738d95
|
|
@ -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}`.");
|
||||
}
|
||||
}
|
||||
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
{
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue