Controllers
ReactivityController
A controller that facilitates real-time reactivity, including user registration, chat messaging, and counter synchronization.
Index
IActionResult Index()
Renders the controller's default view for the reactivity UI.
Returns
An IActionResult that renders the default view.
Sidebar
IActionResult Sidebar()
Renders the sidebar inside a RazorWire frame with the ID "permanent-island".
Returns
An IActionResult that produces the RazorWire frame containing the sidebar content.
UserList
IActionResult UserList()
Renders the UserList view component inside a Turbo/RazorWire frame with the ID "user-list".
Returns
An IActionResult that renders the UserList view component wrapped in a Turbo/RazorWire frame with id "user-list".
RegisterUser
Task<IActionResult> RegisterUser(string username)
Registers the provided username, persists it in an HttpOnly cookie, and broadcasts the user's presence to other clients.
Parameters
usernameThe username submitted from the registration form. If empty or whitespace, no username is persisted or broadcast.
Returns
A Turbo Stream that replaces the message form and updates the register form when the request is a Turbo request; otherwise a redirect to the Index action.
PublishMessage
Task<IActionResult> PublishMessage(string message)
Publishes a chat message to connected clients and returns a Turbo/RazorWire stream or a redirect.
Parameters
messageThe message text submitted from the form.
Returns
`A Turbo/RazorWire` stream that replaces the message form when the request is a Turbo request; otherwise a redirect to the Index action.
IncrementCounter
IActionResult IncrementCounter(int clientCount)
Increments the server and session counters and returns a Turbo/RazorWire stream to update the UI or a safe redirect.
Parameters
clientCountThe current session client count (will be incremented).
Returns
`IActionResult` that is a Turbo stream updating counters for Turbo requests; otherwise a redirect to the referring local URL or the Index action.
BroadcastUserPresenceAsync
Task BroadcastUserPresenceAsync(string username)
Broadcasts a user's presence to connected clients and updates the rendered user list and count.
Parameters
usernameThe display name to mark as active and include in the rendered user list.
HomeController
The default controller for the application, providing the entry point view.
Index
IActionResult Index()
Renders the default view for the Home controller's Index action.
Returns
The view result for the Index action.