Skip to main content

WebSocket Events

Subscribe to real-time events via WebSocket to receive instant updates when data changes in GxP.

Connection Information

GxP uses Pusher for WebSocket connections. You can connect using Laravel Echo or any Pusher-compatible client library.

SettingValueDescription
Protocolwss://Secure WebSocket connection
Hostws-us2.pusher.comPusher US East cluster
Clusterus2US East region
Auth Endpoint/broadcasting/authBearer token authentication

Quick Start

Install the required packages and configure Laravel Echo to connect to GxP WebSocket events:

Installation

Install dependencies
npm install laravel-echo pusher-js

Configuration

echo.js
import Echo from 'laravel-echo';
import Pusher from 'pusher-js';

// Make Pusher available globally (required for Echo)
window.Pusher = Pusher;

// Initialize Echo with your configuration
const echo = new Echo({
broadcaster: 'pusher',
key: process.env.PUSHER_APP_KEY,
cluster: 'us2',
forceTLS: true,
authEndpoint: 'https://api.gramercy.cloud/broadcasting/auth',
auth: {
headers: {
Authorization: `Bearer ${yourAuthToken}`
}
}
});

export default echo;

Subscribing to Events

Subscribe to attendee events
import echo from './echo';

// Subscribe to a private channel for a specific project
const projectSlug = 'my-event-2024';

echo.private(`dashboard.project.${projectSlug}.attendees`)
// Listen for new attendees
.listen('AttendeeCreated', (event) => {
console.log('New attendee:', event.attendee);
// Update your UI with the new attendee
})
// Listen for attendee updates
.listen('AttendeeUpdated', (event) => {
console.log('Attendee updated:', event.attendee);
})
// Listen for attendee deletions
.listen('AttendeeDeleted', (event) => {
console.log('Attendee deleted:', event.attendee_id);
});

// Don't forget to leave the channel when done
// echo.leave(`dashboard.project.${projectSlug}.attendees`);

Channel Types

TypePrefixAuthenticationUse Case
Privateprivate-RequiredUser-specific or project-specific data
Presencepresence-RequiredKnow who is online in a channel
PublicNoneNot requiredBroadcast to all listeners

Event Reference

Below is the complete reference of all WebSocket events available in the GxP platform. Click on any event to expand and see the payload schema.

Best Practices

Connection Management

  • Reuse a single Echo instance across your application
  • Leave channels when components unmount
  • Handle connection errors gracefully
  • Implement reconnection logic for production apps

Performance

  • Only subscribe to channels you need
  • Debounce UI updates for high-frequency events
  • Use presence channels sparingly
  • Consider batching updates for bulk operations