Skip to content
Docs/Client Events
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

RuleSpecificationAction on Violation
Channel Typeprivate- and presence- channels onlyDiscarded silently
Prefix RequirementMust start with client- (e.g. client-typing)Discarded silently
Rate Limit50 events per 10 seconds per socket, 1000 events per 10 seconds per appWire event pusher:error (4301)
Max Payload Size10 KiB (10,240 bytes)Wire event pusher:error (4300)
Socket ExclusionOriginating socket is automatically excludedEnforced by protocol
PersistenceEphemeral 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...`)
})