MqttSession.cs 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. /*
  2. Copyright (c) 2013, 2014 Paolo Patierno
  3. All rights reserved. This program and the accompanying materials
  4. are made available under the terms of the Eclipse Public License v1.0
  5. and Eclipse Distribution License v1.0 which accompany this distribution.
  6. The Eclipse Public License is available at
  7. http://www.eclipse.org/legal/epl-v10.html
  8. and the Eclipse Distribution License is available at
  9. http://www.eclipse.org/org/documents/edl-v10.php.
  10. Contributors:
  11. Paolo Patierno - initial API and implementation and/or initial documentation
  12. */
  13. using System.Collections;
  14. namespace uPLibrary.Networking.M2Mqtt.Session
  15. {
  16. /// <summary>
  17. /// MQTT Session base class
  18. /// </summary>
  19. public abstract class MqttSession
  20. {
  21. /// <summary>
  22. /// Client Id
  23. /// </summary>
  24. public string ClientId { get; set; }
  25. /// <summary>
  26. /// Messages inflight during session
  27. /// </summary>
  28. public Hashtable InflightMessages { get; set; }
  29. /// <summary>
  30. /// Constructor
  31. /// </summary>
  32. public MqttSession()
  33. : this(null)
  34. {
  35. }
  36. /// <summary>
  37. /// Constructor
  38. /// </summary>
  39. /// <param name="clientId">Client Id to create session</param>
  40. public MqttSession(string clientId)
  41. {
  42. this.ClientId = clientId;
  43. this.InflightMessages = new Hashtable();
  44. }
  45. /// <summary>
  46. /// Clean session
  47. /// </summary>
  48. public virtual void Clear()
  49. {
  50. this.ClientId = null;
  51. this.InflightMessages.Clear();
  52. }
  53. }
  54. }