Commit 5eb698f5 by gdj

区分mqtt内外网地址。

parent 159e29c8
......@@ -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,
......
......@@ -517,7 +517,7 @@ public class UserServiceImpl extends ServiceImpl<IUserMapper, UserEntity> implem
UserDTO userDTO = entityConvertToDTO(userEntity);
// 无人机登录 获取外网地址
userDTO.setMqttAddr(MqttPropertyConfiguration.getBasicMqttAddress());
userDTO.setMqttAddr(MqttPropertyConfiguration.getNetMqttAddress());
userDTO.setAccessToken(token);
userDTO.setWorkspaceId(workspaceOpt.get().getWorkspaceId());
userDTO.setRoleType(roleType);
......@@ -1026,7 +1026,7 @@ public class UserServiceImpl extends ServiceImpl<IUserMapper, UserEntity> implem
.roleType(entity.getRoleType())
.mqttUsername(entity.getMqttUsername())
.mqttPassword(entity.getMqttPassword())
.mqttAddr(MqttPropertyConfiguration.getBasicMqttAddress())
.mqttAddr(MqttPropertyConfiguration.getNetMqttAddress())
// 判断密码是否过期
.passwordExpired(isPasswordExpired(entity))
.build();
......
......@@ -62,6 +62,19 @@ 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.cc
port: 443
path: /mqtt
username: JavaServer
password: 123456
BASIC:
protocol: MQTT # @see com.dji.sample.component.mqtt.model.MqttProtocolEnum
# 深圳
......
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