Skip to content

Commit

Permalink
Dev version. Remove passing of unneeded args.
Browse files Browse the repository at this point in the history
  • Loading branch information
Shevchik committed Feb 15, 2016
1 parent 1811999 commit 198f784
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 12 deletions.
2 changes: 1 addition & 1 deletion src/plugin.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: ProtocolSupport
main: protocolsupport.ProtocolSupport
version: 4.22.1
version: 4.23.dev
author: _Shevchik_
load: STARTUP
commands:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,12 +118,12 @@ private void decode(ChannelHandlerContext ctx) throws Exception {
//it was 1.7+ handshake after all
//hope that there won't be any handshake packet with id 0xFA in future because it will be more difficult to support it
cancelTask();
handshakeversion = attemptDecodeNettyHandshake(channel, replayingBuffer);
handshakeversion = attemptDecodeNettyHandshake(replayingBuffer);
}
} else {
//1.7+ handshake
cancelTask();
handshakeversion = attemptDecodeNettyHandshake(channel, replayingBuffer);
handshakeversion = attemptDecodeNettyHandshake(replayingBuffer);
}
} catch (EOFSignal ex) {
}
Expand All @@ -137,19 +137,18 @@ private void decode(ChannelHandlerContext ctx) throws Exception {
break;
}
default: { // >= 1.7 handshake
handshakeversion = attemptDecodeNettyHandshake(channel, replayingBuffer);
handshakeversion = attemptDecodeNettyHandshake(replayingBuffer);
break;
}
}
//if we detected the protocol than we save it and process data
if (handshakeversion != null) {
setProtocol(channel, receivedData, handshakeversion);
setProtocol(channel, handshakeversion);
}
}

protected volatile boolean protocolSet = false;

protected void setProtocol(final Channel channel, final ByteBuf input, ProtocolVersion version) throws Exception {
protected boolean protocolSet = false;
protected void setProtocol(final Channel channel, ProtocolVersion version) throws Exception {
if (protocolSet) {
return;
}
Expand All @@ -160,12 +159,12 @@ protected void setProtocol(final Channel channel, final ByteBuf input, ProtocolV
ProtocolStorage.setProtocolVersion(ChannelUtils.getNetworkManagerSocketAddress(channel), version);
channel.pipeline().remove(ChannelHandlers.INITIAL_DECODER);
pipelineBuilders.get(version).buildPipeLine(channel, version);
input.readerIndex(0);
channel.pipeline().firstContext().fireChannelRead(input);
receivedData.readerIndex(0);
channel.pipeline().firstContext().fireChannelRead(receivedData);
}

//handshake packet has more than 3 bytes for sure, so we can simplify splitting logic
private static ProtocolVersion attemptDecodeNettyHandshake(Channel channel, ByteBuf bytebuf) {
private static ProtocolVersion attemptDecodeNettyHandshake(ByteBuf bytebuf) {
bytebuf.readerIndex(0);
if (bytebuf.readableBytes() < 3) {
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public SetProtocolTask(InitialPacketDecoder initialDecoder, Channel channel, Pro
@Override
public void run() {
try {
initialDecoder.setProtocol(channel, initialDecoder.receivedData, version);
initialDecoder.setProtocol(channel, version);
} catch (Exception t) {
channel.pipeline().firstContext().fireExceptionCaught(t);
}
Expand Down

0 comments on commit 198f784

Please sign in to comment.