Presence Component — sgcHTML | eSeGeCe

Presence

TsgcHTMLComponent_Presence — a "who is online" roster, rendered as an overlapping avatar stack or a list, with status dots and live WebSocket updates, in Delphi, C++ Builder and .NET.

TsgcHTMLComponent_Presence

Add users with AddUser, cap how many show with MaxVisible, then read the HTML property — or push a status change to open clients with GetUserFragmentHTML.

Component class

TsgcHTMLComponent_Presence

Renders

Avatar stack or list, plus scoped CSS

Family

Chat & AI

Languages

Delphi, C++ Builder, .NET

Add users, render it, push status changes

Call AddUser for each person, read HTML for the initial render, then call SetUserStatus and push GetUserFragmentHTML when someone's status changes.

uses
  sgcHTML_Component_Presence;

var
  oPresence: TsgcHTMLComponent_Presence;
begin
  oPresence := TsgcHTMLComponent_Presence.Create(nil);
  try
    oPresence.PresenceID := 'roster';
    oPresence.Layout := plAvatars;
    oPresence.MaxVisible := 5;
    oPresence.Title := 'Online';

    oPresence.AddUser('u1', 'Ana Torres', psOnline);
    oPresence.AddUser('u2', 'Marc Bell', psAway, '', 'Back at 3pm');
    oPresence.AddUser('u3', 'Kenji Ito', psBusy);

    WebModule.Response := oPresence.HTML;   // avatar stack + scoped CSS
  finally
    oPresence.Free;
  end;
end;

// Push a status change to every connected client, no full re-render:
oPresence.SetUserStatus('u2', psOnline);
TsgcHTMX_Engine_Server.BroadcastFragment(oPresence.GetUserFragmentHTML('u2'));
// includes: sgcHTML_Component_Presence.hpp

TsgcHTMLComponent_Presence *oPresence = new TsgcHTMLComponent_Presence(NULL);
try
{
  oPresence->PresenceID = "roster";
  oPresence->Layout = plAvatars;
  oPresence->MaxVisible = 5;
  oPresence->Title = "Online";

  oPresence->AddUser("u1", "Ana Torres", psOnline);
  oPresence->AddUser("u2", "Marc Bell", psAway, "", "Back at 3pm");
  oPresence->AddUser("u3", "Kenji Ito", psBusy);

  String html = oPresence->HTML;   // avatar stack + scoped CSS

  // Push a status change to every connected client:
  oPresence->SetUserStatus("u2", psOnline);
  TsgcHTMX_Engine_Server::BroadcastFragment(oPresence->GetUserFragmentHTML("u2"));
}
__finally
{
  delete oPresence;
}
using esegece.sgcWebSockets;

var presence = new TsgcHTMLComponent_Presence();
presence.PresenceID = "roster";
presence.Layout = TsgcHTMLPresenceLayout.plAvatars;
presence.MaxVisible = 5;
presence.Title = "Online";

presence.AddUser("u1", "Ana Torres", TsgcHTMLPresenceStatus.psOnline);
presence.AddUser("u2", "Marc Bell", TsgcHTMLPresenceStatus.psAway, "", "Back at 3pm");
presence.AddUser("u3", "Kenji Ito", TsgcHTMLPresenceStatus.psBusy);

string html = presence.HTML;   // avatar stack + scoped CSS

// Push a status change to every connected client, no full re-render:
presence.SetUserStatus("u2", TsgcHTMLPresenceStatus.psOnline);
TsgcHTMX_Engine_Server.BroadcastFragment(presence.GetUserFragmentHTML("u2"));

Key properties & methods

The members you reach for most often.

Adding users

AddUser(aId, aDisplayName, aStatus, aAvatarURL, aStatusText) upserts a roster entry: an existing Id is updated in place.

Status

TsgcHTMLPresenceStatuspsOnline, psAway, psBusy, psOffline. SetUserStatus(aId, aStatus, aStatusText) updates just the status dot and text.

Layout

Layout picks plAvatars (overlapping avatar stack) or plList (name + status rows); AvatarSize sets the avatar diameter in pixels.

Overflow cap

MaxVisible (default 5) caps how many users are shown before a "+N" chip appears; every user stays in the markup so a later push still finds it.

Title and ShowCount render a header with an online-count badge; GetOnlineCount excludes psOffline users.

Streaming updates

GetUserFragmentHTML(aId) (also emits a delete once RemoveUser is called), GetCountFragmentHTML and GetMoreFragmentHTML feed TsgcHTMX_Engine_Server.PushFragment / BroadcastFragment.

Keep exploring

Online HelpFull API reference and usage guide for this component.
All sgcHTML ComponentsBrowse the full feature matrix of 80+ components.
Download Free TrialThe 30-day trial ships the 60.HTML demo projects.
PricingSingle, Team and Site licenses with full source code.

Ready to Get Started?

Download the free trial and add a live presence roster to your Delphi, C++ Builder or .NET web app.