Commit 04c142d5 by gdj

区分mqtt内外网地址。

parent 86701127
...@@ -54,6 +54,25 @@ public class MqttPropertyConfiguration { ...@@ -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. * Splice the mqtt address according to the parameters of different clients.
* @param options * @param options
* @return * @return
......
...@@ -8,6 +8,11 @@ package com.dji.sample.component.mqtt.model; ...@@ -8,6 +8,11 @@ package com.dji.sample.component.mqtt.model;
public enum MqttUseEnum { public enum MqttUseEnum {
/** /**
* The broker is used for net link.
*/
NET,
/**
* The broker is used for basic link. * The broker is used for basic link.
*/ */
BASIC, BASIC,
......
...@@ -181,7 +181,8 @@ public class UserServiceImpl extends ServiceImpl<IUserMapper, UserEntity> implem ...@@ -181,7 +181,8 @@ public class UserServiceImpl extends ServiceImpl<IUserMapper, UserEntity> implem
String token = JwtUtil.createToken(customClaim.convertToMap()); String token = JwtUtil.createToken(customClaim.convertToMap());
UserDTO userDTO = entityConvertToDTO(userEntity); UserDTO userDTO = entityConvertToDTO(userEntity);
userDTO.setMqttAddr(MqttPropertyConfiguration.getBasicMqttAddress()); // 无人机登录 获取外网地址
userDTO.setMqttAddr(MqttPropertyConfiguration.getNetMqttAddress());
userDTO.setAccessToken(token); userDTO.setAccessToken(token);
userDTO.setWorkspaceId(workspaceOpt.get().getWorkspaceId()); userDTO.setWorkspaceId(workspaceOpt.get().getWorkspaceId());
userDTO.setRoleType(roleType); userDTO.setRoleType(roleType);
...@@ -684,7 +685,7 @@ public class UserServiceImpl extends ServiceImpl<IUserMapper, UserEntity> implem ...@@ -684,7 +685,7 @@ public class UserServiceImpl extends ServiceImpl<IUserMapper, UserEntity> implem
.roleType(entity.getRoleType()) .roleType(entity.getRoleType())
.mqttUsername(entity.getMqttUsername()) .mqttUsername(entity.getMqttUsername())
.mqttPassword(entity.getMqttPassword()) .mqttPassword(entity.getMqttPassword())
.mqttAddr(MqttPropertyConfiguration.getBasicMqttAddress()) .mqttAddr(MqttPropertyConfiguration.getNetMqttAddress())
.build(); .build();
} }
......
...@@ -62,19 +62,32 @@ jwt: ...@@ -62,19 +62,32 @@ jwt:
mqtt: mqtt:
# @see com.dji.sample.component.mqtt.model.MqttUseEnum # @see com.dji.sample.component.mqtt.model.MqttUseEnum
# BASIC parameters are required. # 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: BASIC:
protocol: MQTT # @see com.dji.sample.component.mqtt.model.MqttProtocolEnum protocol: MQTT # @see com.dji.sample.component.mqtt.model.MqttProtocolEnum
# 深圳 # 深圳
host: 183.11.236.162 # host: 183.11.236.162
port: 54418 # port: 54418
# host: 203.186.109.106 # host: 203.186.109.106
# host: emqx-broker # host: emqx-broker
# host: 192.168.32.90 # host: 192.168.32.90
# port: 44418 # port: 44418
# host: 203.186.109.106 # host: 203.186.109.106
# port: 54941 # port: 54941
# host: emqx-broker host: emqx-broker
# port: 1883 port: 1883
username: JavaServer username: JavaServer
password: 123456 password: 123456
client-id: 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