IoTSharp / MQTTnet.AspNetCore.Routing

Easily create Controllers and Actions to process incoming MQTT messages using a familiar paradigm and MQTTnet

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Async Action Example

seikosantana opened this issue · comments

Hi, i currently have this implementation of the controller:

[MqttController]
[MqttRoute("telemetry")]
public class DeviceTelemetryController: MqttBaseController
{
    public Task NewTelemetry()
    {
        return BadMessage();
    }
}

My question is, how to make the Action async?
Thanks in advance

I'm struggling with how to return data using methods like Ok().

I tried changing the return type to Task<Task> and it can't be invoked.

Seems like the only way to do async with Ok() probably is by await Ok() and then return.

return Task.CompletedTask;

yes but that is not asynchronous and it doens't make use of Ok() and the others

I think it is possible to do like in the README of #6