Skip to main content

Client-Server Calls

The reusable gauge (SimpleGauge : Widget, "Boiler 3") gains a command API — the server sets the value and resets the animation with one-way Call, reads the rendered size with an awaited CallAsync, and gets the selected client-side state back as a small camel-cased DTO.

Nothing here is deployed anywhere; it is a plain Wisej.NET 4 project that runs on your machine.

Run it

cd "LearnWisej-Samples/Application Integration Course\Module 6\IntegrationLab"
dotnet run -f net10.0 --urls http://localhost:5076

Then open http://localhost:5076. (Visual Studio: open IntegrationLab.slnx, press F5 — the port is in Properties/launchSettings.json.)

Requirements: .NET 10 SDK, the Wisej-4 4.1.0 NuGet package. dotnet build -nologo -v q passes; warning CS7022 (Program.Main ignored) is expected.

What to click in the Gauge Commands window

The four commands under the gauge; the right-hand card is the Server ⇄ Client · command trace.

ButtonMechanismWhat you should see
Set value (72)Call("setValue", 72) — one-wayone → .NET→JS Call("setValue", 72) line; the needle sweeps to 72
Read rendered sizeawait CallAsync("getRenderedSize")→ await CallAsync("getRenderedSize"), then ← JS→.NET result {"width":480,"height":244} on a later timestamp; the next statement picks "wide"/"compact" and updates the caption
Reset animationCall("resetAnimation") — one-wayone queued call, the gauge plays its settle animation, nothing comes back
Get selected stateawait CallAsync("getSelectedState")GaugeStateDto← JS→.NET result {"value":72,"isAboveThreshold":false,"width":480,"height":244,"isAnimating":false}

A queued Call produces one line; an awaited CallAsync produces a result line later. Failures (a rejected value, a browser that does not reply within 5 s, a vendor error reported by the adapter) show on the banner under the gauge.

Where things live

IntegrationLab/
├─ Controls/
│ ├─ SimpleGauge.cs server widget: typed state + command API (Call / CallAsync)
│ └─ GaugeEventArgs.cs event payload types (data, never behavior)
├─ Contracts/
│ ├─ GaugeStateDto.cs the client-state DTO (5 primitives, camelCase on the wire)
│ └─ RenderedSize.cs the CallAsync("getRenderedSize") result
├─ wwwroot/
│ ├─ gauge-init.js client wrapper (InitScript, embedded): setValue / resetAnimation / getRenderedSize / getSelectedState
│ └─ vendor-gauge.js the "third-party" VendorGauge library (Package)
├─ docs/ the three deliverables + the object-model note
├─ Window1.cs / .Designer.cs Gauge Commands window (async void handlers with try/catch)
├─ Program.cs Wisej.NET session entry point
└─ Startup.cs Kestrel host (app.UseWisej())