Table of Contents

Class PresenceTracker

Namespace
EchoHub.Server.Services
Assembly
EchoHub.Server.dll
public class PresenceTracker
Inheritance
PresenceTracker
Inherited Members

Constructors

PresenceTracker()

public PresenceTracker()

Methods

ForceRemoveUser(string)

Forcibly remove a user from all tracking. Returns their connection IDs and channels so the caller can broadcast departures and force-disconnect connections.

public (List<string> ConnectionIds, List<string> Channels) ForceRemoveUser(string username)

Parameters

username string

Returns

(List<string> ConnectionIds, List<string> Channels)

GetChannelsForUser(string)

public List<string> GetChannelsForUser(string username)

Parameters

username string

Returns

List<string>

GetConnectionsInChannels(List<string>)

Get all unique connection IDs for users who share any of the given channels.

public List<string> GetConnectionsInChannels(List<string> channels)

Parameters

channels List<string>

Returns

List<string>

GetOnlineUserCount()

public int GetOnlineUserCount()

Returns

int

GetOnlineUsersInChannel(string)

public List<string> GetOnlineUsersInChannel(string channelName)

Parameters

channelName string

Returns

List<string>

GetUsernameForConnection(string)

public string? GetUsernameForConnection(string connectionId)

Parameters

connectionId string

Returns

string

IsOnline(string)

public bool IsOnline(string username)

Parameters

username string

Returns

bool

JoinChannel(string, string)

Returns true if this is a new join, false if the user was already in the channel.

public bool JoinChannel(string username, string channelName)

Parameters

username string
channelName string

Returns

bool

LeaveChannel(string, string)

public void LeaveChannel(string username, string channelName)

Parameters

username string
channelName string

UserConnected(string, Guid, string)

public void UserConnected(string connectionId, Guid userId, string username)

Parameters

connectionId string
userId Guid
username string

UserDisconnected(string)

public string? UserDisconnected(string connectionId)

Parameters

connectionId string

Returns

string

Events

UserCountChanged

Raised when the distinct online user count changes (multi-connection users only fire once).

public event Action<int>? UserCountChanged

Event Type

Action<int>