Skip to content

Commit 589a21a

Browse files
committed
Finish final Service server pipeline injection.
1 parent a4ee599 commit 589a21a

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

src/main/java/org/ros/internal/transport/tcp/TcpServerHandshakeHandler.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,14 +78,28 @@ private void handleServiceHandshake(ChannelHandlerContext ctx, ConnectionHeader
7878
DefaultServiceServer<?, ?> serviceServer = serviceManager.getServer(serviceName);
7979
// finishHandshake previously returned ByteBuffer, now returns ConnectionHeader
8080
ctx.write(serviceServer.finishHandshake(incomingHeader));
81+
if( DEBUG ) {
82+
log.info("Service server "+serviceServer+" ChannelHandlerContext:"+ctx+" for:"+this);
83+
}
8184
String probe = incomingHeader.getField(ConnectionHeaderFields.PROBE);
8285
if (probe != null && probe.equals("1")) {
8386
ctx.close();
8487
} else {
8588
//ctx.pipeline().remove(TcpServerPipelineFactory.LENGTH_FIELD_PREPENDER);
89+
// Once the handshake is complete, remove the handshake handler and replace it with the service request handler
8690
ctx.pipeline().remove(TcpServerPipelineFactory.HANDSHAKE_HANDLER);
8791
//pipeline.addLast("ServiceResponseEncoder", new ServiceResponseEncoder());
8892
ctx.pipeline().addLast("ServiceRequestHandler", serviceServer.newRequestHandler());
93+
// Set this context ready to receive the message type specified
94+
synchronized(ctx.getMessageTypes()) {
95+
ctx.getMessageTypes().add(incomingHeader.getField(ConnectionHeaderFields.TYPE));
96+
}
97+
// The handshake is complete and the only task is to set the context ready, which will allow
98+
// the outbound queue to start sending messages.
99+
ctx.setReady(true);
100+
if( DEBUG ) {
101+
log.info("Service description complete for:"+serviceServer+", ChannelHandlerContext:"+ctx+" for:"+this);
102+
}
89103
}
90104
}
91105
/**

0 commit comments

Comments
 (0)