Commit 04c142d5 by gdj

区分mqtt内外网地址。

parent 86701127
......@@ -54,6 +54,25 @@ public class MqttPropertyConfiguration {
}
/**
* Get the configuration options of the net link of the mqtt client.
* @return
*/
static MqttClientOptions getNetClientOptions() {
if (!mqtt.containsKey(MqttUseEnum.NET)) {
throw new Error("Please configure the net mqtt connection parameters first, otherwise application cannot be started.");
}
return mqtt.get(MqttUseEnum.NET);
}
/**
* Get the mqtt address of the net link.
* @return
*/
public static String getNetMqttAddress() {
return getMqttAddress(getNetClientOptions());
}
/**
* Splice the mqtt address according to the parameters of different clients.
* @param options
* @return
......
......@@ -8,6 +8,11 @@ package com.dji.sample.component.mqtt.model;
public enum MqttUseEnum {
/**
* The broker is used for net link.
*/
NET,
/**
* The broker is used for basic link.
*/
BASIC,
......
......@@ -181,7 +181,8 @@ public class UserServiceImpl extends ServiceImpl<IUserMapper, UserEntity> implem
String token = JwtUtil.createToken(customClaim.convertToMap());
UserDTO userDTO = entityConvertToDTO(userEntity);
userDTO.setMqttAddr(MqttPropertyConfiguration.getBasicMqttAddress());
// 无人机登录 获取外网地址
userDTO.setMqttAddr(MqttPropertyConfiguration.getNetMqttAddress());
userDTO.setAccessToken(token);
userDTO.setWorkspaceId(workspaceOpt.get().getWorkspaceId());
userDTO.setRoleType(roleType);
......@@ -684,7 +685,7 @@ public class UserServiceImpl extends ServiceImpl<IUserMapper, UserEntity> implem
.roleType(entity.getRoleType())
.mqttUsername(entity.getMqttUsername())
.mqttPassword(entity.getMqttPassword())
.mqttAddr(MqttPropertyConfiguration.getBasicMqttAddress())
.mqttAddr(MqttPropertyConfiguration.getNetMqttAddress())
.build();
}
......
......@@ -62,19 +62,32 @@ jwt:
mqtt:
# @see com.dji.sample.component.mqtt.model.MqttUseEnum
# BASIC parameters are required.
NET:
# protocol: MQTT # @see com.dji.sample.component.mqtt.model.MqttProtocolEnum
# host: 183.11.236.162
# port: 54418
# username: JavaServer
# password: 123456
# client-id: 123456
protocol: WSS
host: geofly.geotwin.cn
port: 443
path: /mqtt
username: JavaServer
password: 123456
BASIC:
protocol: MQTT # @see com.dji.sample.component.mqtt.model.MqttProtocolEnum
# 深圳
host: 183.11.236.162
port: 54418
# host: 183.11.236.162
# port: 54418
# host: 203.186.109.106
# host: emqx-broker
# host: 192.168.32.90
# port: 44418
# host: 203.186.109.106
# port: 54941
# host: emqx-broker
# port: 1883
host: emqx-broker
port: 1883
username: JavaServer
password: 123456
client-id: 123456
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment