本文整理了Java中org.fusesource.mqtt.client.MQTT.setHost()
方法的一些代码示例,展示了MQTT.setHost()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。MQTT.setHost()
方法的具体详情如下:
包路径:org.fusesource.mqtt.client.MQTT
类名称:MQTT
方法名:setHost
暂无
代码示例来源:origin: fusesource/mqtt-client
public void setHost(String host) throws URISyntaxException {
this.setHost(new URI(host));
}
public void setHost(URI host) {
代码示例来源:origin: fusesource/mqtt-client
public void setHost(String host, int port) throws URISyntaxException {
this.setHost(new URI("tcp://"+host+":"+port));
}
public void setHost(String host) throws URISyntaxException {
代码示例来源:origin: apache/storm
/**
* Initializes {@code connection}.
* @throws Exception if an exception during connecting to connector occurs
*/
public static void startPublisher() throws Exception {
MQTT client = new MQTT();
client.setTracer(new MqttLogger());
client.setHost("tcp://localhost:1883");
client.setClientId("MqttBrokerPublisher");
connection = client.blockingConnection();
Runtime.getRuntime().addShutdownHook(new Thread() {
@Override
public void run() {
try {
LOG.info("Shutting down MQTT client...");
connection.disconnect();
} catch (Exception e) {
e.printStackTrace();
}
}
});
connection.connect();
}
代码示例来源:origin: andsel/moquette
@Before
public void setUp() throws Exception {
startServer();
m_mqtt = new MQTT();
m_mqtt.setHost("localhost", 1883);
}
代码示例来源:origin: fusesource/mqtt-client
main.mqtt.setVersion(shift(argl));
} else if ("-h".equals(arg)) {
main.mqtt.setHost(shift(argl));
} else if ("-k".equals(arg)) {
main.mqtt.setKeepAlive(Short.parseShort(shift(argl)));
代码示例来源:origin: fusesource/mqtt-client
main.mqtt.setVersion(shift(argl));
} else if ("-h".equals(arg)) {
main.mqtt.setHost(shift(argl));
} else if ("-k".equals(arg)) {
main.mqtt.setKeepAlive(Short.parseShort(shift(argl)));
代码示例来源:origin: apache/storm
URI uri = URI.create(options.getUrl());
client.setHost(uri);
if (!uri.getScheme().toLowerCase().equals("tcp")) {
client.setSslContext(SslUtils.sslContext(uri.getScheme(), keyStoreLoader));
代码示例来源:origin: andsel/moquette
mqtt.setHost("localhost", 1883);
mqtt.setClientId("WillTestamentPublisher");
mqtt.setWillRetain(false);
m_publisher.connect();
m_mqtt.setHost("localhost", 1883);
m_mqtt.setCleanSession(false);
m_mqtt.setClientId("Subscriber");
代码示例来源:origin: org.fusesource.mqtt-client/mqtt-client
public void setHost(String host, int port) throws URISyntaxException {
this.setHost(new URI("tcp://"+host+":"+port));
}
public void setHost(String host) throws URISyntaxException {
代码示例来源:origin: org.fusesource.mqtt-client/mqtt-client
public void setHost(String host) throws URISyntaxException {
this.setHost(new URI(host));
}
public void setHost(URI host) {
代码示例来源:origin: tuanhiep/mqtt-jmeter
private FutureConnection createConnection(String host,String clientId) {
try {
MQTT client = new MQTT();
client.setHost(host);
client.setClientId(clientId);
return client.futureConnection();
} catch (URISyntaxException e) {
getLogger().error(e.getMessage());
return null;
}
}
private FutureConnection createConnection(String host,String clientId,String user, String password) {
代码示例来源:origin: dempeZheng/forest-chat
public void init(String host, int port) throws Exception {
mqtt = new MQTT();
mqtt.setHost(host, port);
mqtt.setUserName(uid);
mqtt.setPassword(pwd);
mqtt.setClientId(uid);
}
代码示例来源:origin: tuanhiep/mqtt-jmeter
private CallbackConnection createConnection(String host, String clientId,
boolean durable) throws URISyntaxException {
MQTT client = new MQTT();
client.setHost(host);
client.setClientId(clientId);
client.setCleanSession(!durable);
return client.callbackConnection();
}
代码示例来源:origin: tuanhiep/mqtt-jmeter
private FutureConnection createConnection(String host,String clientId,String user, String password) {
try {
MQTT client = new MQTT();
client.setHost(host);
client.setUserName(user);
client.setPassword(password);
client.setClientId(clientId);
return client.futureConnection();
} catch (URISyntaxException e) {
getLogger().error(e.getMessage());
return null;
}
}
代码示例来源:origin: tuanhiep/mqtt-jmeter
private CallbackConnection createConnection(String host, String clientId,
boolean durable, String user, String password)
throws URISyntaxException {
MQTT client = new MQTT();
client.setHost(host);
client.setClientId(clientId);
client.setUserName(user);
client.setPassword(password);
client.setCleanSession(!durable);
return client.callbackConnection();
}
代码示例来源:origin: apache/activemq-artemis
private static BlockingConnection retrieveMQTTConnection(String host) throws Exception {
MQTT mqtt = new MQTT();
mqtt.setHost(host);
BlockingConnection connection = mqtt.blockingConnection();
connection.connect();
return connection;
}
}
代码示例来源:origin: apache/activemq-artemis
private static BlockingConnection retrieveMQTTConnection(String host) throws Exception {
MQTT mqtt = new MQTT();
mqtt.setHost(host);
BlockingConnection connection = mqtt.blockingConnection();
connection.connect();
return connection;
}
代码示例来源:origin: apache/activemq-artemis
@Override
public void connect(String host) throws Exception {
mqtt.setHost(host);
mqtt.setVersion("3.1.1");
// shut off connect retry
mqtt.setConnectAttemptsMax(0);
mqtt.setReconnectAttemptsMax(0);
connection = mqtt.blockingConnection();
connection.connect();
}
代码示例来源:origin: apache/activemq-artemis
private MQTT createMQTTTcpConnection(String clientId, boolean clean) throws Exception {
MQTT mqtt = new MQTT();
mqtt.setConnectAttemptsMax(1);
mqtt.setReconnectAttemptsMax(0);
mqtt.setTracer(createTracer());
mqtt.setVersion("3.1.1");
if (clientId != null) {
mqtt.setClientId(clientId);
}
mqtt.setCleanSession(clean);
mqtt.setHost("localhost", port);
return mqtt;
}
代码示例来源:origin: apache/activemq-artemis
private BlockingConnection retrieveMQTTConnection(String host, String truststorePath, String truststorePass, String keystorePath, String keystorePass) throws Exception {
MQTT mqtt = new MQTT();
mqtt.setConnectAttemptsMax(1);
mqtt.setReconnectAttemptsMax(0);
mqtt.setHost(host);
SSLContext sslContext = new SSLSupport()
.setKeystorePath(keystorePath)
.setKeystorePassword(keystorePass)
.setTruststorePath(truststorePath)
.setTruststorePassword(truststorePass)
.createContext();
mqtt.setSslContext(sslContext);
BlockingConnection connection = mqtt.blockingConnection();
connection.connect();
return connection;
}
内容来源于网络,如有侵权,请联系作者删除!