Native Conveyor / Presence Native mode
Presence
Presence tracks which sockets are connected to a channel in native Conveyor mode.
Using Laravel Echo's.join()?See Presence for Laravel Echo →
Native presence
Enable presence on the server:
php
Constants::USE_PRESENCE => trueWhen a socket connects to or disconnects from a channel, Conveyor broadcasts a presence payload to that channel. The presence event name is channel-presence, sent in the normal native action envelope:
jsonserver → channel
{
"action": "channel-connect",
"data": "{\"event\":\"channel-presence\",\"channel\":\"chat.room.1\",\"fds\":[1]}",
"fd": 1
}Customize the payload with these filters:
FILTER_PRESENCE_MESSAGE_CONNECT
Constants::FILTER_PRESENCE_MESSAGE_CONNECTFILTER_PRESENCE_MESSAGE_DISCONNECT
Constants::FILTER_PRESENCE_MESSAGE_DISCONNECTAssociate users in native mode
To link a user to the current socket fd, send assoc-user-to-fd-action with a userId:
jsonclient → server
{
"action": "assoc-user-to-fd-action",
"userId": 1
}Use authentication or middleware before trusting a user-provided id.
Next steps
- For presence channels with Laravel Echo —
.join(),.here(), whispers — see Presence in the Laravel section. - Native presence is independent of Laravel Echo. It uses the
channel-presenceevent plus the optional user association action.