File tree Expand file tree Collapse file tree 1 file changed +29
-0
lines changed
ExampleServer/MqttControllers Expand file tree Collapse file tree 1 file changed +29
-0
lines changed Original file line number Diff line number Diff line change
1
+ using System . Threading . Tasks ;
2
+ using Microsoft . Extensions . Logging ;
3
+ using MQTTnet . AspNetCore . Routing ;
4
+ using MQTTnet . AspNetCore . Routing . Attributes ;
5
+
6
+ namespace ExampleServer . MqttControllers ;
7
+
8
+ [ MqttController ]
9
+ public class ViewModelController : MqttBaseController
10
+ {
11
+ private ILogger < ViewModelController > Logger { get ; }
12
+
13
+ public ViewModelController ( ILogger < ViewModelController > logger )
14
+ {
15
+ Logger = logger ;
16
+ }
17
+
18
+ [ MqttRoute ( "viewmodel/{sender}" ) ]
19
+ public Task DeserializeViewModel ( string sender , [ FromPayload ] SamplePayload payload )
20
+ {
21
+ Logger . LogInformation ( "{Sender} says {Message}" , sender , payload . Message ) ;
22
+ return Accepted ( ) ;
23
+ }
24
+ }
25
+
26
+ public class SamplePayload
27
+ {
28
+ public string Message { get ; set ; }
29
+ }
You can’t perform that action at this time.
0 commit comments