Skip to content

Commit

Permalink
修改mqtt
Browse files Browse the repository at this point in the history
  • Loading branch information
puyang1017 committed Mar 19, 2020
1 parent 77d45c6 commit 1a611e4
Showing 1 changed file with 20 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import org.eclipse.paho.client.mqttv3.persist.MemoryPersistence;

import javax.net.SocketFactory;
import javax.net.ssl.HostnameVerifier;

import java.security.InvalidKeyException;
import java.security.NoSuchAlgorithmException;
Expand Down Expand Up @@ -59,6 +60,10 @@ private MqttV3(Builder builder) {
mMqttConnectOptions.setMqttVersion(this.mqttVersion);
mMqttConnectOptions.setKeepAliveInterval(this.keepAliveInterval);
mMqttConnectOptions.setConnectionTimeout(this.connectionTimeout);
mMqttConnectOptions.setHttpsHostnameVerificationEnabled(this.httpsHostnameVerificationEnabled);
if (sslHostnameVerifier != null) {
mMqttConnectOptions.setSSLHostnameVerifier(this.sslHostnameVerifier);
}
if (this.socketFactory != null) {
mMqttConnectOptions.setSocketFactory(this.socketFactory);
}
Expand Down Expand Up @@ -408,6 +413,8 @@ public void publishMsg(String topic, int qos, boolean retained, byte[] msg, IPub
private boolean publishMsgRetained;
private Object userContext = null;
private SocketFactory socketFactory;
private boolean httpsHostnameVerificationEnabled = true;
private HostnameVerifier sslHostnameVerifier = null;
private IReceiveActionListener mIReceiveActionListener;
private IMqttStatusListener mIMqttStatusListener;

Expand Down Expand Up @@ -473,9 +480,22 @@ public static class Builder {
private boolean publishMsgRetained = true;
private Object userContext = null;
private SocketFactory socketFactory;
private boolean httpsHostnameVerificationEnabled = true;
private HostnameVerifier sslHostnameVerifier = null;
private IReceiveActionListener mIReceiveActionListener;
private IMqttStatusListener mIMqttStatusListener;


public Builder setHttpsHostnameVerificationEnabled(boolean httpsHostnameVerificationEnabled) {
this.httpsHostnameVerificationEnabled = httpsHostnameVerificationEnabled;
return this;
}

public Builder setSslHostnameVerifier(HostnameVerifier sslHostnameVerifier) {
this.sslHostnameVerifier = sslHostnameVerifier;
return this;
}

/**
* @param isAlibabaCloud 是否是阿里云mqtt
*/
Expand Down

0 comments on commit 1a611e4

Please sign in to comment.