# Real Time Web Applications

From [Wikipedia](https://en.wikipedia.org/wiki/Real-time_web):

*The real-time web is a network web using technologies and practices that enable users to receive information as soon as it is published by its authors, rather than requiring that they or their software check a source periodically for updates.*

## Fundamentals of Real Time Web Applications

In our view, a Real Time Web Application must be able to:

* Update the user's browser (client) seamlessly at any time, as if directly connected to the server
* Receive events and updates from the client without delay

Web-based video games exemplify Real Time Web. Wisej.NET extends this concept to Line of Business Applications.

## WebSocket or Polling

When the server supports WebSocket connections, Wisej.NET "pushes" real-time updates to the client at any time. A background task can update connected clients asynchronously by calling `Application.Update()`.

Some servers or browsers may not support WebSocket connections and can only use HTTP requests. In these cases, the server cannot contact the browser directly since each HTTP request starts and terminates when the browser contacts the server. One solution is to create a `Wisej.Web.Timer` to periodically fire server events and allow Wisej.NET to update the client.

SignalR emulates WebSocket connections using "long polling" - keeping a pending request open to allow server responses, then opening a new suspended request. However:

* Each request blocks a thread
* Prone to timeout errors
* Browsers limit open AJAX requests (4-8), risking request blocking

Without WebSocket support, use automatic polling in Wisej.NET:

* Call `Application.StartPolling()` and `Application.EndPolling()`
* Configure polling `Interval` in the [configuration](https://docs.wisej.com/docs/concepts/configuration) file for non-WebSocket clients

{% hint style="success" %}
Wisej.NET sends all updates since the last request back to the client with each request. With a background task but no WebSocket connection, the browser updates on every event (timer, click, etc.).
{% endhint %}

## Main Real Time Features in Wisej.NET

| Feature                | Description                                                                                                                                                                                       |
| ---------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Push updates           | Wisej.NET applications can update the client during a request or asynchronously from a background task                                                                                            |
| Modal workflow         | Server-side business logic, UI logic, or UI code can display modal dialogs/message boxes and suspend execution until closure                                                                      |
| Complete session state | Application state stays synchronized between client/server - refresh at any time to reload full state including modals                                                                            |
| Live events            | Server code responds to real-time pointer events (mouse movement, wheel, control enter/leave)                                                                                                     |
| Remote methods         | Server code can call client JavaScript and vice-versa at any time                                                                                                                                 |
| Drawing and painting   | Controls can draw/paint on the client browser using HTML5 `<canvas>`. See the [ProgressCircle](http://wisej.com/extensions/) extension and [CustomPainting](http://wisej.com/extensions/) example |


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.wisej.com/docs/concepts/real-time-web-applications.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
