IMqttNetworkChannel.cs 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  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;
  14. using System.Text;
  15. namespace uPLibrary.Networking.M2Mqtt
  16. {
  17. /// <summary>
  18. /// Interface for channel under MQTT library
  19. /// </summary>
  20. public interface IMqttNetworkChannel
  21. {
  22. /// <summary>
  23. /// Data available on channel
  24. /// </summary>
  25. bool DataAvailable { get; }
  26. /// <summary>
  27. /// Receive data from the network channel
  28. /// </summary>
  29. /// <param name="buffer">Data buffer for receiving data</param>
  30. /// <returns>Number of bytes received</returns>
  31. int Receive(byte[] buffer);
  32. /// <summary>
  33. /// Receive data from the network channel with a specified timeout
  34. /// </summary>
  35. /// <param name="buffer">Data buffer for receiving data</param>
  36. /// <param name="timeout">Timeout on receiving (in milliseconds)</param>
  37. /// <returns>Number of bytes received</returns>
  38. int Receive(byte[] buffer, int timeout);
  39. /// <summary>
  40. /// Send data on the network channel to the broker
  41. /// </summary>
  42. /// <param name="buffer">Data buffer to send</param>
  43. /// <returns>Number of byte sent</returns>
  44. int Send(byte[] buffer);
  45. /// <summary>
  46. /// Close the network channel
  47. /// </summary>
  48. void Close();
  49. /// <summary>
  50. /// Connect to remote server
  51. /// </summary>
  52. void Connect();
  53. /// <summary>
  54. /// Accept client connection
  55. /// </summary>
  56. void Accept();
  57. }
  58. }