Tags: Models, Call methods, Client subscriptions
A simple text field that can be edited by multiple clients simultaneously.
- Install NATS Server and Resgate (done with 3 docker commands).
git clone https://github.com/jirenius/csharp-res
Open the solution, examples\02_EditText\EditText.sln
, in Visual Studio 2017.
Set multiple startup projects with the projects below (how to). Press F5 to build and run.
- TextService
- WebClient
Open the client
http://localhost:8081
- Open the client in two separate tabs.
- Edit the message in one tab, and observe realtime updates in both.
- Stop the service.
- Edit the default text in MyModelHandler.cs.
- Restart the service to observe resetting of the message in all clients.
Request | Resource | Description |
---|---|---|
get | text.mymodel |
Simple model. |
call | text.mymodel.set |
Sets the model's message property. |
Resources can be retrieved using ordinary HTTP GET requests, and methods can be called using HTTP POST requests.
GET http://localhost:8080/api/text/mymodel
POST http://localhost:8080/api/text/mymodel/set
Body
{ "message": "Updated through HTTP" }