Simple UDP Proxy
Mission:
To design and program two projects one to be a REST Service and one to be a UDP proxy - receive UDP datagrams and send REST post method.
Background:
Previous exercises REST service & UDP server
To simulate a sensor download this package (FakeSensor.zip) unpack and run the sensor - 'GenericSensorBroadcaster.exe'.
This will send out message-lines like :
{"SensorName":Room D3.06,"Temperature":19,"CO2":900} heading PORT 10100
Assignment A: Make a REST service for Sensor data
- In Visual Studio Create 3 projects:
- Create a new solution 'ConsoleApp (.Net Core)', and name it e.g. 'UDPProxy'.
- Create a new Project 'ASP.NET Core Web Api', and name it e.g. 'SensorREST'.
- Create a new Project 'Class Libray (.Net Core)' and name it e.g. 'ModelLib'.
- In the ModelLib create one model classes
- a 'SensorData' with the properties 'Id, Name, Temperature, CO2'
- In the 'SensorREST' Create a controller 'SensorsController' with corresponding manager 'SensorManager'
- In the controller and manager - make three methods
- Get All - to get all sensor data in the rest api
- Get one specified by the Id
- Create a new instance of Sensor Data i.e. a POST method
- Try your REST service with Postman or Swagger
Assignment B: Make a Proxy
- In the UDPProxy i.e. make a new class Proxy and create a Start method.
- In the start method in a loop :
- Receive UDP datagrams from the Sensor (e.g. port 10100)
- Make and send a POST request to your REST service
- Start your Fake Sensor, your REST Service and your Proxy
- Try from time to time to get all from your rest service from a browser.