use of org.springframework.web.socket.config.annotation.WebSocketHandlerRegistry in project steve by RWTH-i5-IDSG.
the class WebSocketConfiguration method registerWebSocketHandlers.
@Override
public void registerWebSocketHandlers(WebSocketHandlerRegistry registry) {
WebSocketPolicy policy = new WebSocketPolicy(WebSocketBehavior.SERVER);
policy.setMaxTextMessageBufferSize(MAX_MSG_SIZE);
policy.setMaxTextMessageSize(MAX_MSG_SIZE);
policy.setIdleTimeout(IDLE_TIMEOUT);
List<AbstractWebSocketEndpoint> endpoints = getEndpoints();
String[] protocols = endpoints.stream().map(e -> e.getVersion().getValue()).toArray(String[]::new);
OcppWebSocketUpgrader upgradeStrategy = new OcppWebSocketUpgrader(policy, endpoints, chargePointRepository, notificationService, chargePointHelperService);
DefaultHandshakeHandler handler = new DefaultHandshakeHandler(upgradeStrategy);
handler.setSupportedProtocols(protocols);
for (AbstractWebSocketEndpoint endpoint : endpoints) {
registry.addHandler(endpoint, "/websocket/CentralSystemService/*").setHandshakeHandler(handler).setAllowedOrigins("*");
}
}
Aggregations