Skip to content

Commit

Permalink
Added protocol service bean to configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
sepehr-gh committed Dec 12, 2020
1 parent 20b684a commit 35a9066
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 9 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
</parent>
<groupId>lab.idioglossia</groupId>
<artifactId>row-server-starter</artifactId>
<version>2.0.1-RELEASE</version>
<version>2.0.2-RELEASE</version>
<name>Springboot Rest Over Websocket Starter</name>
<description>Spring boot starter for Rest Over Websocket</description>
<developers>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,11 +128,16 @@ public RowWsListener rowWsListener(){
return new RowWsListener.DummyRowWsListener();
}

@Bean("protocolService")
@DependsOn("rowFilterChain")
public ProtocolService protocolService(RowFilterChain rowFilterChain){
return new ProtocolService(rowFilterChain);
}

@Bean("rowWebSocketHandler")
@DependsOn({"rowSessionRegistry", "rowFilterChain", "rowWsListener", "subscriptionRegistry"})
public WebSocketHandler rowWebSocketHandler(RowSessionRegistry rowSessionRegistry, RowFilterChain rowFilterChain, RowWsListener rowWsListener, SubscriptionRegistry subscriptionRegistry){
return new RowWebSocketHandler(rowSessionRegistry, webSocketProperties, rowFilterChain, rowWsListener, subscriptionRegistry, handlerProperties.isTrackHeartbeats());
@DependsOn({"rowSessionRegistry", "protocolService", "rowWsListener", "subscriptionRegistry"})
public WebSocketHandler rowWebSocketHandler(RowSessionRegistry rowSessionRegistry, ProtocolService protocolService, RowWsListener rowWsListener, SubscriptionRegistry subscriptionRegistry){
return new RowWebSocketHandler(rowSessionRegistry, webSocketProperties, rowWsListener, subscriptionRegistry, protocolService, handlerProperties.isTrackHeartbeats());
}

@Bean("subscriptionRegistry")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import lab.idioglossia.row.server.config.Naming;
import lab.idioglossia.row.server.config.properties.WebSocketProperties;
import lab.idioglossia.row.server.domain.RowWebsocketSession;
import lab.idioglossia.row.server.filter.RowFilterChain;
import lab.idioglossia.row.server.repository.RowSessionRegistry;
import lab.idioglossia.row.server.repository.SubscriptionRegistry;
import lab.idioglossia.row.server.service.ProtocolService;
Expand All @@ -20,18 +19,18 @@
public class RowWebSocketHandler extends TextWebSocketHandler {
private final RowSessionRegistry rowSessionRegistry;
private final WebSocketProperties webSocketProperties;
private final ProtocolService protocolService;
private final RowWsListener rowWsListener;
private final SubscriptionRegistry subscriptionRegistry;
private final ProtocolService protocolService;
private final boolean trackHeartbeats;

public RowWebSocketHandler(RowSessionRegistry rowSessionRegistry, WebSocketProperties webSocketProperties, RowFilterChain rowFilterChain, RowWsListener rowWsListener, SubscriptionRegistry subscriptionRegistry, boolean trackHeartbeats) {
public RowWebSocketHandler(RowSessionRegistry rowSessionRegistry, WebSocketProperties webSocketProperties, RowWsListener rowWsListener, SubscriptionRegistry subscriptionRegistry, ProtocolService protocolService, boolean trackHeartbeats) {
this.rowSessionRegistry = rowSessionRegistry;
this.webSocketProperties = webSocketProperties;
this.rowWsListener = rowWsListener;
this.subscriptionRegistry = subscriptionRegistry;
this.protocolService = protocolService;
this.trackHeartbeats = trackHeartbeats;
protocolService = new ProtocolService(rowFilterChain);
}

@Override
Expand Down Expand Up @@ -80,7 +79,7 @@ public boolean supportsPartialMessages() {

//--------------------

private void updateHeartbeat(WebSocketSession session) {
public void updateHeartbeat(WebSocketSession session) {
if(trackHeartbeats)
session.getAttributes().put(Naming.IN_HEARTBEAT_ATTRIBUTE_NAME, new Date());
}
Expand Down

0 comments on commit 35a9066

Please sign in to comment.