本文整理了Java中org.fusesource.mqtt.client.MQTT.callbackConnection()
方法的一些代码示例,展示了MQTT.callbackConnection()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。MQTT.callbackConnection()
方法的具体详情如下:
包路径:org.fusesource.mqtt.client.MQTT
类名称:MQTT
方法名:callbackConnection
暂无
代码示例来源:origin: fusesource/mqtt-client
public FutureConnection futureConnection() {
return new FutureConnection(callbackConnection());
}
public BlockingConnection blockingConnection() {
代码示例来源:origin: apache/storm
private void connectMqtt() throws Exception {
String clientId = this.topologyName + "-" + this.context.getThisComponentId() + "-" +
this.context.getThisTaskId();
MQTT client = MqttUtils.configureClient(this.options, clientId, this.keyStoreLoader);
this.connection = client.callbackConnection();
this.connection.listener(this);
this.connection.connect(new ConnectCallback());
while (!this.mqttConnected && !this.mqttConnectFailed) {
LOG.info("Waiting for connection...");
Thread.sleep(500);
}
if (this.mqttConnected) {
List<String> topicList = this.options.getTopics();
Topic[] topics = new Topic[topicList.size()];
QoS qos = MqttUtils.qosFromInt(this.options.getQos());
for (int i = 0; i < topicList.size(); i++) {
topics[i] = new Topic(topicList.get(i), qos);
}
connection.subscribe(topics, new SubscribeCallback());
}
}
代码示例来源:origin: fusesource/mqtt-client
private void execute() {
final CallbackConnection connection = mqtt.callbackConnection();
代码示例来源:origin: fusesource/mqtt-client
private void execute() {
final CallbackConnection connection = mqtt.callbackConnection();
代码示例来源:origin: org.fusesource.mqtt-client/mqtt-client
public FutureConnection futureConnection() {
return new FutureConnection(callbackConnection());
}
public BlockingConnection blockingConnection() {
代码示例来源: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: org.fusesource.mqtt-client/mqtt-client
private void execute() {
final CallbackConnection connection = mqtt.callbackConnection();
代码示例来源:origin: org.fusesource.mqtt-client/mqtt-client
private void execute() {
final CallbackConnection connection = mqtt.callbackConnection();
代码示例来源: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: org.eclipse.kapua/kapua-client-gateway-provider-fuse
@Override
public FuseChannel build() throws Exception {
final URI broker = Objects.requireNonNull(broker(), "Broker must be set");
final String clientId = Strings.nonEmptyText(clientId(), "clientId");
final MqttNamespace namespace = Objects.requireNonNull(namespace(), "Namespace must be set");
final BinaryPayloadCodec codec = Objects.requireNonNull(codec(), "Codec must be set");
final MQTT mqtt = new MQTT();
mqtt.setCleanSession(false);
mqtt.setHost(broker);
mqtt.setClientId(clientId);
final Object credentials = credentials();
if (credentials == null) {
// none
} else if (credentials instanceof UserAndPassword) {
final UserAndPassword userAndPassword = (UserAndPassword) credentials;
mqtt.setUserName(userAndPassword.getUsername());
mqtt.setPassword(userAndPassword.getPasswordAsString());
} else {
throw new IllegalStateException(
String.format("Unknown credentials type: %s", credentials.getClass().getName()));
}
final CallbackConnection connection = mqtt.callbackConnection();
final FuseChannel result = new FuseChannel(clientId, namespace, codec, connection);
return result;
}
}
代码示例来源:origin: eclipse/kapua
@Override
public FuseChannel build() throws Exception {
final URI broker = Objects.requireNonNull(broker(), "Broker must be set");
final String clientId = Strings.nonEmptyText(clientId(), "clientId");
final MqttNamespace namespace = Objects.requireNonNull(namespace(), "Namespace must be set");
final BinaryPayloadCodec codec = Objects.requireNonNull(codec(), "Codec must be set");
final MQTT mqtt = new MQTT();
mqtt.setCleanSession(false);
mqtt.setHost(broker);
mqtt.setClientId(clientId);
final Object credentials = credentials();
if (credentials == null) {
// none
} else if (credentials instanceof UserAndPassword) {
final UserAndPassword userAndPassword = (UserAndPassword) credentials;
mqtt.setUserName(userAndPassword.getUsername());
mqtt.setPassword(userAndPassword.getPasswordAsString());
} else {
throw new IllegalStateException(
String.format("Unknown credentials type: %s", credentials.getClass().getName()));
}
final CallbackConnection connection = mqtt.callbackConnection();
final FuseChannel result = new FuseChannel(clientId, namespace, codec, connection);
return result;
}
}
代码示例来源:origin: com.sitewhere/sitewhere-core
connection = mqtt.callbackConnection();
createListener();
connection.connect(new Callback<Void>() {
代码示例来源:origin: sitewhere/sitewhere
connection = mqtt.callbackConnection();
createListener();
connection.connect(new Callback<Void>() {
内容来源于网络,如有侵权,请联系作者删除!