Search
 
SCRIPT & CODE EXAMPLE
 

PHP

laravel websockets onsubscribe

// Add websocket routes "AppProvidersRouteServiceProvider.php"
public function map()
{
    $this->mapApiRoutes();

    $this->mapWebRoutes();
  
    $this->app->singleton('websockets.router', function () {
        return new Router();
    });
}

// Create WebSocket Router "AppWebSocketsRoute.php"
class Router extends BeyondCodeLaravelWebSocketsServerRouter
{
    public function echo()
    {
        $this->get('/app/{appKey}', WebSocketHandler::class);
        $this->post('/apps/{appId}/events', TriggerEventController::class);
        $this->get('/apps/{appId}/channels', FetchChannelsController::class);
        $this->get('/apps/{appId}/channels/{channelName}', FetchChannelController::class);
        $this->get('/apps/{appId}/channels/{channelName}/users', FetchUsersController::class);
    }
}

// Create WebSocket Router "AppWebSocketsWebSocketHandler.php"
class WebSocketHandler extends BeyondCodeLaravelWebSocketsWebSocketsWebSocketHandler
{
    public function onMessage(ConnectionInterface $connection, MessageInterface $message)
    {
        parent::onMessage($connection, $message);
        $message = json_decode($message->getPayload(), true);
        if ($message['event'] === 'pusher:subscribe') { 
      		// Your code here...
        }
    }
}
Comment

PREVIOUS NEXT
Code Example
Php :: Flutter Error - Migrate to android studio - MAC OS 
Php :: how to create wordpress shortcodes 
Php :: php clone 
Php :: php requuire once 
Php :: percentage in php 
Php :: symfony datetime now 
Php :: register_post_type wordpress 
Php :: laravel foreign key constraint 
Php :: php eliminar elementos vacios array 
Php :: csv file to associative array php 
Php :: acf repeater 
Php :: how to display image in wordpress 
Php :: how to get current location in laravel 
Php :: how to get yesterday date in laravel 
Php :: hide error in php 
Php :: php artisan update table 
Php :: php fix array keys 
Php :: Fatal error: Allowed memory size of 1610612736 bytes exhausted 
Php :: unset session key 
Php :: symfony doctrine existing database 
Php :: wp_query order by taxonomy 
Php :: laravel delete 
Php :: allow json uploads in Wordpress 
Php :: migrate particular file laravel 
Php :: php utc time 
Php :: javascript date to php date 
Php :: livewire inline component 
Php :: for loop in laravel 
Php :: Append a text string to WooCommerce single product title 
Php :: join multiple tables in laravel eloquent 
ADD CONTENT
Topic
Content
Source link
Name
5+7 =