Realtime
Xams provides built-in support for real-time communication between server and client using SignalR.
Creating a Hub
Xams uses a single SignalR hub per browser window instance for optimal performance. You can create service-specific hubs using the ServiceHub attribute and implementing the IServiceHub interface.
Project/Hubs/ChatHub.cs
Hub Permissions
Hub access is controlled through role-based permissions.

Modifying hub permissions forces affected clients to reconnect, causing temporary disconnection.
The IServiceHub interface defines four methods with specific permission requirements:
IServiceHub Interface
Client Implementation
The client connects to the hub using the appContext.signalR() method, which returns a singleton SignalR connection for the browser window.
src/pages/Chat.tsx
The framework automatically handles connection initialization via
appContext.signalR(), reconnection on disconnect, and connection state
tracking via appContext.signalRState
Sending Messages from Services
Service classes (Actions, Jobs, or Service Logic) can send messages to clients using the HubSend method, which invokes the hub's Send method.
Project/Service/WidgetService.cs
The HubSend method executes in a new database transaction, independent of
the current service's transaction context.
The hub's Send method processes server-side messages (see complete example above).
The Clients.All property sends messages to all connected clients across the
entire application, not just those connected to this specific hub. Use groups
to target specific client subsets.
Dependency Injection
ServiceHub classes support constructor-based dependency injection: