use of org.openremote.container.util.UniqueIdentifierGenerator in project openremote by openremote.
the class MQTTProtocol method doCreateIoClient.
@Override
protected MQTT_IOClient doCreateIoClient() throws Exception {
String host = agent.getHost().orElse(null);
int port = agent.getPort().orElseGet(() -> {
if (agent.isSecureMode().orElse(false)) {
return agent.isWebsocketMode().orElse(false) ? 443 : 8883;
} else {
return agent.isWebsocketMode().orElse(false) ? 80 : 1883;
}
});
URI websocketURI = null;
if (agent.isWebsocketMode().orElse(false)) {
URIBuilder builder = new URIBuilder().setHost(host).setPort(port);
agent.getWebsocketPath().ifPresent(builder::setPath);
agent.getWebsocketQuery().map(query -> query.startsWith("?") ? query.substring(1) : query).ifPresent(builder::setCustomQuery);
websocketURI = builder.build();
}
return new MQTT_IOClient(agent.getClientId().orElseGet(UniqueIdentifierGenerator::generateId), host, port, agent.isSecureMode().orElse(false), !agent.isResumeSession().orElse(false), agent.getUsernamePassword().orElse(null), websocketURI);
}
Aggregations