๐Ÿ”Œ Olshoperp WebSocket

Laravel Reverb + Echo โ€” in a nutshell

๐Ÿ“ก Connection Flow

Browser (Vue + Echo)
  โ†“ WSS :443
NGINX (SSL + WS Upgrade)
  โ†“ Proxy
Laravel Reverb
  โ†“
Authorized Channels
  โ†“
Vue UI (Toast / Status)
      

๐Ÿงช Example Usage

This example demonstrates the ToastNotification feature. Once the job completes, a toast notification is triggered and broadcast to targeted users, companies, or pages.

$data = [
    'message'     => 'Your Message',
    'title'       => 'Your Title' // Not used since the title was removed in FE,
    'type'        =>
        $exception
            ? 'error'
            : 'info',

    // Targeting
    'user_ids'    => [$this->user->id],
    'company_ids' => [] // This line can be removed, or the array can be emptied,
    'pages'       => [] // This line can be removed, or the array can be emptied,
];

// Safety wrap prevents exception from killing job
try {
    event(
        new ToastNotification($data)
    );
} catch (\Throwable $e) {
    Log::warning(
        "Broadcast ToastNotification failed: "
        . $e->getMessage()
    );
}
  
Rule of Thumb
โ€ข All empty โ†’ GLOBAL broadcast
โ€ข Add one โ†’ Scoped
โ€ข Add more โ†’ Hyper-targeted
โ–ถ๏ธ Demo GIF / Video goes here

๐Ÿงฉ Channel Architecture

Real-time broadcasting โ€” explained from config to runtime

1๏ธโƒฃ Channel Hierarchy

feature โ†’ scope โ†’ channel[]

Channels are organized in layers: feature groups events, scope limits who can listen, and channels define the final path.

2๏ธโƒฃ Scope

global
All users
user
Single user
company
Company-wide
team / room
Custom group

Scope decides who is allowed to receive the event. It acts as a security boundary.

3๏ธโƒฃ Channel Patterns

global-toast-notification
toast-notification.user-{id}
page-toast-notification.{page}
page-process-status.{page}.company-{id}

Channel names follow patterns so the backend can authorize and match them dynamically.

4๏ธโƒฃ Runtime Flow

Event Fired
  โ†“
Pattern Matched
  โ†“
Scope Authorized
  โ†“
Listeners Updated
      

Placeholders are filled at runtime to target the right users, pages, or environments.

Core Idea

Events are dumb.
Channels decide who hears them.