PusherServer.Presence (pusher_server v0.1.0)

Copy Markdown View Source

Tracks presence-channel membership for one instance. Keyed internally by socket_id so a user with multiple tabs/connections works correctly: member_added only fires for a user_id's first connection, member_removed only fires when their last connection drops.

Every instance gets its own Presence process (named via PusherServer.Naming.presence/1), so two embedded instances never share membership state.

This is the in-memory presence store used by PusherServer.Backend.Local (single node). When :redis_url is set the Redis backend keeps presence in Redis instead and this process is not started.

Summary

Functions

Returns true if this is the first connection for that user_id on the channel.

Returns a specification to start this module under a supervisor.

Returns list of {user_id, user_info} for current unique members.

Returns {is_last_connection_for_user, user_id} or {false, nil} if not found.

Functions

add(server, channel, socket_id, user_id, user_info)

Returns true if this is the first connection for that user_id on the channel.

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

members(server, channel)

Returns list of {user_id, user_info} for current unique members.

remove(server, channel, socket_id)

Returns {is_last_connection_for_user, user_id} or {false, nil} if not found.