# Class PresenceTracker | EchoHub Documentation

# Class PresenceTracker

Namespace
  EchoHub.Server.Services

Assembly
  EchoHub.Server.dll

    public class PresenceTracker

Inheritance
  object
  PresenceTracker

Inherited Members
  object.GetType()
  object.MemberwiseClone()
  object.ToString()
  object.Equals(object)
  object.Equals(object, object)
  object.ReferenceEquals(object, object)
  object.GetHashCode()

## 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

### IsIrcOnly(string)

True when the user is online exclusively through the IRC gateway. A user who also has a native client connected has full features, so they don't count as IRC-only.

    public bool IsIrcOnly(string username)

#### Parameters

`username` string

#### Returns

bool

### 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>