本文整理汇总了Java中org.eclipse.paho.client.mqttv3.IMqttClient.getClientId方法的典型用法代码示例。如果您正苦于以下问题:Java IMqttClient.getClientId方法的具体用法?Java IMqttClient.getClientId怎么用?Java IMqttClient.getClientId使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.paho.client.mqttv3.IMqttClient
的用法示例。
在下文中一共展示了IMqttClient.getClientId方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: MqttV3Receiver
import org.eclipse.paho.client.mqttv3.IMqttClient; //导入方法依赖的package包/类
/**
* @param mqttClient
* @param reportStream
*/
public MqttV3Receiver(IMqttClient mqttClient, PrintStream reportStream) {
String methodName = Utility.getMethodName();
log.entering(className, methodName);
this.reportStream = reportStream;
connected = true;
clientId = mqttClient.getClientId();
log.exiting(className, methodName);
}
示例2: testConnect
import org.eclipse.paho.client.mqttv3.IMqttClient; //导入方法依赖的package包/类
/**
* @throws Exception
*/
public void testConnect() throws Exception {
IMqttClient client = null;
try {
String clientId = "testConnect";
client = new MqttClient(serverURI, clientId);
System.out.println("Connecting...(serverURI:" + serverURI + ", ClientId:" + clientId);
client.connect();
String clientId2 = client.getClientId();
System.out.println("clientId = " + clientId2);
boolean isConnected = client.isConnected();
System.out.println("isConnected = " + isConnected);
String id = client.getServerURI();
System.out.println("ServerURI = " + id);
client.disconnect();
System.out.println("Disconnecting...");
client.connect();
System.out.println("Re-Connecting...");
client.disconnect();
System.out.println("Disconnecting...");
}
catch (MqttException exception) {
System.out.println("Unexpected exception: " + exception);
}
finally {
if (client != null) {
System.out.println("Close...");
client.close();
}
}
}
示例3: testConnect
import org.eclipse.paho.client.mqttv3.IMqttClient; //导入方法依赖的package包/类
/**
* @throws Exception
*/
@Test
public void testConnect() throws Exception {
String methodName = Utility.getMethodName();
LoggingUtilities.banner(log, cclass, methodName);
IMqttClient client = null;
try {
String clientId = methodName;
client = clientFactory.createMqttClient(serverURI, clientId);
log.info("Connecting...(serverURI:" + serverURI + ", ClientId:" + clientId);
client.connect();
String clientId2 = client.getClientId();
log.info("clientId = " + clientId2);
boolean isConnected = client.isConnected();
log.info("isConnected = " + isConnected);
String id = client.getServerURI();
log.info("ServerURI = " + id);
log.info("Disconnecting...");
client.disconnect();
log.info("Re-Connecting...");
client.connect();
log.info("Disconnecting...");
client.disconnect();
}
catch (MqttException exception) {
log.log(Level.SEVERE, "caught exception:", exception);
Assert.fail("Unexpected exception: " + exception);
}
finally {
if (client != null) {
log.info("Close...");
client.close();
}
}
}
示例4: MqttV3Receiver
import org.eclipse.paho.client.mqttv3.IMqttClient; //导入方法依赖的package包/类
/**
* @param mqttClient
* @param reportStream
*/
public MqttV3Receiver(IMqttClient mqttClient, PrintStream reportStream) {
this.reportStream = reportStream;
connected = true;
clientId = mqttClient.getClientId();
}