/// <summary> /// Creates an <see cref="IMqttServer"/> over the TCP protocol, using the /// specified MQTT configuration to customize the protocol parameters. /// </summary> /// <param name="configuration"> /// The configuration used for creating the Server. /// See <see cref="MqttConfiguration" /> for more details about the supported values. /// </param> /// <param name="authenticationProvider"> /// Optional authentication provider to use, /// to enable authentication as part of the connection mechanism. /// See <see cref="IMqttAuthenticationProvider" /> for more details about how to implement /// an authentication provider. /// </param> /// <returns>A new MQTT Server</returns> /// <exception cref="MqttServerException">MqttServerException</exception> public static IMqttServer Create(MqttConfiguration configuration, IMqttAuthenticationProvider authenticationProvider = null) => new MqttServerFactory(authenticationProvider).CreateServer(configuration);
/// <summary> /// Creates an <see cref="IMqttClient"/> and connects it to the destination /// <paramref name="hostAddress"/> server via TCP using the specified /// MQTT configuration to customize the protocol parameters. /// </summary> public static Task <IMqttClient> CreateAsync(string hostAddress, MqttConfiguration configuration) => new MqttClientFactory(hostAddress).CreateClientAsync(configuration);
/// <summary> /// Creates an <see cref="IMqttClient"/> and connects it to the destination /// <paramref name="hostAddress"/> server using the specified transport binding /// and MQTT configuration to customize the protocol parameters. /// </summary> /// <param name="hostAddress"> /// Host address to use for the connection /// </param> /// <param name="configuration"> /// The configuration used for creating the Client. /// See <see cref="MqttConfiguration" /> for more details about the supported values. /// </param> /// <param name="binding"> /// The binding to use as the underlying transport layer. /// Deafault value: <see cref="TcpBinding"/> /// Possible values: <see cref="TcpBinding"/>, <see cref="WebSocketBinding"/> /// See <see cref="IMqttBinding"/> for more details about how /// to implement a custom binding /// </param> /// <returns>A new MQTT Client</returns> public static Task <IMqttClient> CreateAsync(string hostAddress, MqttConfiguration configuration, IMqttBinding binding = null) => new MqttClientFactory(hostAddress, binding ?? new TcpBinding()).CreateClientAsync(configuration);
/// <summary> /// Creates an <see cref="IMqttServer"/> using the specified MQTT configuration /// to customize the protocol parameters, and an optional transport binding and authentication provider. /// </summary> /// <param name="configuration"> /// The configuration used for creating the Server. /// See <see cref="MqttConfiguration" /> for more details about the supported values. /// </param> /// <param name="binding"> /// The binding to use as the underlying transport layer. /// Deafault value: <see cref="ServerTcpBinding"/> /// Possible values: <see cref="ServerTcpBinding"/>, <see cref="ServerWebSocketBinding"/> /// See <see cref="IMqttServerBinding"/> for more details about how /// to implement a custom binding /// </param> /// <param name="authenticationProvider"> /// Optional authentication provider to use, /// to enable authentication as part of the connection mechanism. /// See <see cref="IMqttAuthenticationProvider" /> for more details about how to implement /// an authentication provider. /// </param> /// <returns>A new MQTT Server</returns> /// <exception cref="MqttServerException">MqttServerException</exception> public static IMqttServer Create(MqttConfiguration configuration, IMqttServerBinding binding = null, IMqttAuthenticationProvider authenticationProvider = null) => new MqttServerFactory(binding ?? new ServerTcpBinding(), authenticationProvider).CreateServer(configuration);