|
@ -33,6 +33,7 @@ public class WebSocketCommandBusImpl implements CommandBus { |
|
|
private Integer packetIndex = 0; |
|
|
private Integer packetIndex = 0; |
|
|
|
|
|
|
|
|
private final String COMMAND_BUS_WEBSOCKET_URL; |
|
|
private final String COMMAND_BUS_WEBSOCKET_URL; |
|
|
|
|
|
private final Boolean commandBusEnable; |
|
|
|
|
|
|
|
|
public static final int PACKET_TYPE_CMD = 0xA0; |
|
|
public static final int PACKET_TYPE_CMD = 0xA0; |
|
|
public static final int PACKET_TYPE_ACK = 0xA1; |
|
|
public static final int PACKET_TYPE_ACK = 0xA1; |
|
@ -40,14 +41,15 @@ public class WebSocketCommandBusImpl implements CommandBus { |
|
|
public static final int PACKET_TYPE_EVENT = 0xA3; |
|
|
public static final int PACKET_TYPE_EVENT = 0xA3; |
|
|
|
|
|
|
|
|
//TODO 配置硬件服务段ws链接 |
|
|
//TODO 配置硬件服务段ws链接 |
|
|
public WebSocketCommandBusImpl(@Value("${command_bus.websocket_server_url}") String websocketServerUrl) throws DeploymentException, IOException { |
|
|
|
|
|
|
|
|
public WebSocketCommandBusImpl(@Value("${command_bus.websocket_server_url}") String websocketServerUrl, @Value("${command_bus.enable}") Boolean commandBusEnable) throws DeploymentException, IOException { |
|
|
this.COMMAND_BUS_WEBSOCKET_URL = websocketServerUrl; |
|
|
this.COMMAND_BUS_WEBSOCKET_URL = websocketServerUrl; |
|
|
|
|
|
this.commandBusEnable = commandBusEnable; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@Scheduled(fixedRate = 5000) |
|
|
@Scheduled(fixedRate = 5000) |
|
|
@PostConstruct |
|
|
@PostConstruct |
|
|
public void connectToCommandBusWebSocketServer() throws DeploymentException, IOException { |
|
|
public void connectToCommandBusWebSocketServer() throws DeploymentException, IOException { |
|
|
if (this.session == null || !this.session.isOpen()) { |
|
|
|
|
|
|
|
|
if (commandBusEnable && (this.session == null || !this.session.isOpen())) { |
|
|
WebSocketContainer container = ContainerProvider.getWebSocketContainer(); |
|
|
WebSocketContainer container = ContainerProvider.getWebSocketContainer(); |
|
|
URI endpointURI = URI.create(COMMAND_BUS_WEBSOCKET_URL); |
|
|
URI endpointURI = URI.create(COMMAND_BUS_WEBSOCKET_URL); |
|
|
try { |
|
|
try { |
|
|