MqttClientStatus.cs 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. using MQTTnet.Formatter;
  2. using System;
  3. using System.Threading.Tasks;
  4. namespace MQTTnet.Server.Status
  5. {
  6. public class MqttClientStatus : IMqttClientStatus
  7. {
  8. readonly MqttClientConnection _connection;
  9. public MqttClientStatus(MqttClientConnection connection)
  10. {
  11. _connection = connection ?? throw new ArgumentNullException(nameof(connection));
  12. }
  13. public string ClientId { get; set; }
  14. public string Endpoint { get; set; }
  15. public MqttProtocolVersion ProtocolVersion { get; set; }
  16. public DateTime LastPacketReceivedTimestamp { get; set; }
  17. public DateTime ConnectedTimestamp { get; set; }
  18. public DateTime LastNonKeepAlivePacketReceivedTimestamp { get; set; }
  19. public long ReceivedApplicationMessagesCount { get; set; }
  20. public long SentApplicationMessagesCount { get; set; }
  21. public long ReceivedPacketsCount { get; set; }
  22. public long SentPacketsCount { get; set; }
  23. public IMqttSessionStatus Session { get; set; }
  24. public long BytesSent { get; set; }
  25. public long BytesReceived { get; set; }
  26. public Task DisconnectAsync()
  27. {
  28. return _connection.StopAsync();
  29. }
  30. public void ResetStatistics()
  31. {
  32. _connection.ResetStatistics();
  33. }
  34. }
  35. }