Skip to content

Commit 365b42a

Browse files
committed
Allow JSONClient reconfiguration when connected
The WebSocket library allows changing the ping interval immediately during an ongoing connection. Expose this capability by adding a new reconfigure() method to the JSONClient class. To make use of this, set the updated PING_INTERVAL_PARAMETER on the JSONConfiguration object passed to the JSONClient constructor, then invoke JSONClient#reconfigure().
1 parent b163057 commit 365b42a

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

OCPP-J/src/main/java/eu/chargetime/ocpp/WebSocketTransmitter.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,9 @@ byte[] joinByteArrays(byte[] a, byte[] b) {
152152
}
153153

154154
void configure() {
155+
if (client == null) {
156+
return;
157+
}
155158
client.setReuseAddr(configuration.getParameter(JSONConfiguration.REUSE_ADDR_PARAMETER, false));
156159
client.setTcpNoDelay(
157160
configuration.getParameter(JSONConfiguration.TCP_NO_DELAY_PARAMETER, false));

ocpp-v1_6/src/main/java/eu/chargetime/ocpp/JSONClient.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,14 @@ public JSONClient enableWSS(WssSocketBuilder wssSocketBuilder) {
144144
return this;
145145
}
146146

147+
/**
148+
* Applies JSONConfiguration changes when already connected. Specifically, the WebSocket ping
149+
* interval can be changed without reconnecting by calling this method.
150+
*/
151+
public void reconfigure() {
152+
transmitter.configure();
153+
}
154+
147155
@Override
148156
public void addFeatureProfile(Profile profile) {
149157
featureRepository.addFeatureProfile(profile);

0 commit comments

Comments
 (0)