Skip to content

Commit

Permalink
Handle response to event gateway ping messages.
Browse files Browse the repository at this point in the history
  • Loading branch information
stuartcaunt committed Nov 15, 2024
1 parent 3d87a7d commit 5d65a9f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,13 @@ public void unsubscribe(final EventChannelSubscription subscription) {
}

public void forwardEventFromClient(final String clientId, final ClientEventCarrier clientEventCarrier) {
this.messageBroker.broadcast(new ClientEventCarrierMessage(clientId, clientEventCarrier));
if (clientEventCarrier.type().equals("ping")) {
// Handle simple ping-pong keep-alive messages
this.sendEventToClient(clientId, "pong");

} else {
this.messageBroker.broadcast(new ClientEventCarrierMessage(clientId, clientEventCarrier));
}
}

public void sendEventToUser(final String userId, String type) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package eu.ill.visa.web.gateway.sockets;

import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import eu.ill.visa.broker.domain.models.ClientEventCarrier;
Expand All @@ -12,6 +13,10 @@ public class ClientEventCarrierEncoderDecoder implements Encoder.Text<ClientEven
private static final Logger logger = LoggerFactory.getLogger(ClientEventCarrierEncoderDecoder.class);
private final ObjectMapper mapper = new ObjectMapper();

public ClientEventCarrierEncoderDecoder() {
this.mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
}

@Override
public ClientEventCarrier decode(String message) throws DecodeException {
try {
Expand Down

0 comments on commit 5d65a9f

Please sign in to comment.