Docs/Events
Client Events
Client events (whispers) specification, rules, and rate limits.
Specification
Client events (referred to as whispers in Laravel Echo) allow connected clients to broadcast ephemeral messages directly to other channel subscribers without routing through an application backend.
Protocol Rules & Constraints
| Rule | Specification | Action on Violation |
|---|---|---|
| Channel Type | private- and presence- channels only | Discarded silently |
| Prefix Requirement | Must start with client- (e.g. client-typing) | Discarded silently |
| Rate Limit | 50 events per 10 seconds per socket, 1000 events per 10 seconds per app | Wire event pusher:error (4301) |
| Max Payload Size | 10 KiB (10,240 bytes) | Wire event pusher:error (4300) |
| Socket Exclusion | Originating socket is automatically excluded | Enforced by protocol |
| Persistence | Ephemeral only (no queueing or storage) | Inherent |
Presence Channel Identity Injection
When a client event is dispatched on a presence channel, Socketo automatically attaches the sender's authenticated user_id as top-level metadata:
json
{
"event": "client-cursor-move",
"channel": "presence-canvas",
"data": { "x": 420, "y": 180 },
"user_id": "user_42"
}Client SDK Reference
JavaScript (pusher-js)
ts
const channel = pusher.subscribe('private-chat')
channel.bind('pusher:subscription_succeeded', () => {
// Trigger client event
channel.trigger('client-typing', {
userId: 'user_42',
isTyping: true,
})
})
// Listen for peer client event
channel.bind('client-typing', (data: { userId: string; isTyping: boolean }) => {
console.log('Typing status:', data.userId, data.isTyping)
})Laravel Echo (Whispers)
js
const chat = Echo.private(`chat.${roomId}`)
// Send whisper
chat.whisper('typing', { name: 'Alice' })
// Listen for whispers
chat.listenForWhisper('typing', (e) => {
console.log(`${e.name} is typing...`)
})