# SSE-Demo **Repository Path**: hemashuo/SSE-Demo ## Basic Information - **Project Name**: SSE-Demo - **Description**: 此存储库包含一个技术展示,演示了如何在Delphi中实现和使用服务器发送事件(SSE)。它重点展示了单个WebBroker服务器如何通过SSE同时向Web浏览器和本地应用程序推送实时数据。 包含两个主要项目: SSEServer:一个控制台WebBroker服务器,负责托管Web应用程序并广播SSE事件。 FMXSSEClient:一个原生FireMonkey桌面应用程序,使用相同的SSE流。 - **Primary Language**: Delphi - **License**: Not specified - **Default Branch**: main - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2026-04-05 - **Last Updated**: 2026-04-05 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # RAD Studio SSE Demo (Server-Sent Events) ![SSE screenshot](.github/images/SSE.gif) This repository contains a technical showcase demonstrating how to implement and consume **Server-Sent Events (SSE)** in Delphi. It highlights how a single WebBroker server can simultaneously push real-time data to both Web browsers and native applications via SSE. The demo consists of two main projects: 1. **SSEServer**: A console WebBroker server that hosts the web application and broadcasts SSE events. 2. **FMXSSEClient**: A native FireMonkey desktop application that consumes the same SSE stream. ## Features Demonstrated - **Real-time Server-Sent Events (SSE)** using Delphi's `Web.WebBroker` and `TWebResponseStream`. - **Background Job Progress**: Simulates a long-running process on the server pushing percent progress to the clients. - **Throttling & Cadence**: Setting intervals via URL parameters (`hbMs` and `dashMs`) so clients control their update frequency. - **Cross-Platform Clients**: Shows the same SSE technology integrated into a Web page via `EventSource` and natively into Delphi using `THTTPEventSource`. --- ## How to Run ### 1. Start the Server 1. Open `SSEDemo.groupproj` in Delphi. 2. Compile and Run the **SSEServer** project. 3. The server runs as a console application. By default, it will start HTTP services on port `8080`. 4. In the server console window, type `start` to run the service. ### 2. Run the Clients You have two ways to see the demo working (and you can run multiple at the same time!): **Option A: The Web Version** 1. With the server running, open a web browser. 2. Navigate to `http://localhost:8080`. 3. You will see a web dashboard demonstrating the live Dashboard KPIs, background job controls, and an event log. **Option B: The FireMonkey (FMX) Client** 1. In Delphi, compile and run the **FMXSSEClient** project. 2. Once the app opens, click **Connect**. 3. It will connect to the same `localhost:8080` server and display the identical live metrics natively. ### Pushing Data * Try opening a web client and the FMX client side-by-side. * Click the "Start Job" button on either client. You will see both clients update their progress bars in real-time as the server broadcasts the job's progress.