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.
| Setting | Value | Description |
|---|---|---|
| Protocol | wss:// | Secure WebSocket connection |
| Host | ws-us2.pusher.com | Pusher US East cluster |
| Cluster | us2 | US East region |
| Auth Endpoint | /broadcasting/auth | Bearer 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
| Type | Prefix | Authentication | Use Case |
|---|---|---|---|
| Private | private- | Required | User-specific or project-specific data |
| Presence | presence- | Required | Know who is online in a channel |
| Public | None | Not required | Broadcast 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