use Illuminate\Support\Facades\Route;
use Illuminate\Support\Facades\Auth;
Route::get('/ws-client', function () {
Auth::loginUsingId(1); // here we authorize for the sake of the example.
return view('ws-client', [
'protocol' => config('broadcasting.connections.conveyor.protocol'),
'uri' => config('broadcasting.connections.conveyor.host'),
'wsPort' => config('broadcasting.connections.conveyor.port'),
'channel' => 'private-my-channel',
]);
});
// file: server.php
er;
use Conveyor\Events\MessageReceivedEvent;
use Conveyor\Events\PreServerStartEvent;
(new ConveyorServer())
// if you want to see messages in the console
->eventListeners([
Conveyor\Constants::WEBSOCKET_SERVER_TOKEN => 'my-secure-conveyor-token',
Conveyor\Constants::EVENT_MESSAGE_RECEIVED => function (MessageReceivedEvent $event) {
var_dump($event->data);
},
])
->port(8181)
->start();