Presence

Presence tracks who is connected to a channel in native Conveyor mode.


Native presence

Enable presence on the server:

1Constants::USE_PRESENCE => true

When a socket connects to or disconnects from a channel, Conveyor broadcasts a presence payload to that channel. The presence event name is channel-presence.

The message is sent inside the normal native action envelope:

1{
2  "action": "channel-connect",
3  "data": "{\"event\":\"channel-presence\",\"channel\":\"chat.room.1\",\"fds\":[1]}",
4  "fd": 1
5}

The presence payload can be customized with:

1Constants::FILTER_PRESENCE_MESSAGE_CONNECT
2Constants::FILTER_PRESENCE_MESSAGE_DISCONNECT

Associate users in native mode

If your application needs to associate a user with the current socket fd, send:

1{
2  "action": "assoc-user-to-fd-action",
3  "userId": 1
4}

Use authentication or middleware before trusting a user-provided id.

Next steps

For presence channels with Laravel Echo (.join(), .here(), whispers, etc.), see the dedicated Presence page under the Laravel section.

Native presence is independent of Laravel Echo and uses the channel-presence action plus an optional user association action.