in tchannel-core/src/main/java/com/uber/tchannel/handlers/InitRequestInitiator.java [45:79]
protected void channelRead0(ChannelHandlerContext ctx, ByteBuf buf) throws TChannelError {
buf.touch("InitRequestInitiator.channelRead0(...)");
Frame frame = MessageCodec.decode(
MessageCodec.decode(buf)
);
switch (frame.getType()) {
case InitResponse:
InitResponseFrame initResponseFrameMessage = (InitResponseFrame) frame;
if (initResponseFrameMessage.getVersion() == InitFrame.DEFAULT_VERSION) {
ctx.pipeline().remove(this);
peerManager.setIdentified(ctx.channel(), initResponseFrameMessage.getHeaders());
} else {
// This will lead to a connection reset
throw new TChannelProtocol(
String.format("Expected Protocol version: %d, got version: %d",
InitFrame.DEFAULT_VERSION, initResponseFrameMessage.getVersion())
);
}
break;
default:
// This will lead to a connection reset
throw new TChannelProtocol(
"Frame recieved before Init Response" // FIXME typo
);
}
}