ConnectionInfo renaming, ByteBuf writeXXX method switched.

This commit is contained in:
Kyle Fricilone
2016-06-08 17:50:06 -04:00
committed by Adam
parent 1c9d8b1363
commit 16d00403a6
4 changed files with 37 additions and 25 deletions

View File

@@ -110,7 +110,18 @@ public class CacheClient
public void stop()
{
group.shutdownGracefully();
try
{
channel.closeFuture().sync();
}
catch (InterruptedException e)
{
logger.warn(null, e);
}
finally
{
group.shutdownGracefully();
}
}
public int getClientRevision()
@@ -224,9 +235,7 @@ public class CacheClient
buf.writeByte(request.getIndex() == 255 ? 1 : 0);
int hash = pf.computeHash();
buf.writeByte(hash >> 16);
buf.writeByte(hash >> 8);
buf.writeByte(hash);
buf.writeMedium(hash);
logger.trace("Sending request for {}/{}", index, fileId);

View File

@@ -62,7 +62,7 @@ public class CacheClientHandler extends ChannelInboundHandlerAdapter
msg.setRevision(client.getClientRevision());
ByteBuf message = Unpooled.buffer(5);
message.writeByte(msg.getVersion()); // handshake type
message.writeByte(msg.getType()); // handshake type
message.writeInt(msg.getRevision()); // client revision
ctx.writeAndFlush(message);
@@ -97,10 +97,8 @@ public class CacheClientHandler extends ChannelInboundHandlerAdapter
ConnectionInfo cinfo = new ConnectionInfo();
ByteBuf outbuf = Unpooled.buffer(4);
outbuf.writeByte(cinfo.getVar1());
outbuf.writeByte(cinfo.getVar2() >> 16);
outbuf.writeByte(cinfo.getVar2() >> 8);
outbuf.writeByte(cinfo.getVar2());
outbuf.writeByte(cinfo.getType());
outbuf.writeMedium(cinfo.getPadding());
ctx.writeAndFlush(outbuf);
state = ClientState.CONNECTED;
@@ -110,7 +108,7 @@ public class CacheClientHandler extends ChannelInboundHandlerAdapter
ByteBuf copy = buffer.slice();
int index = copy.readUnsignedByte();
int file = copy.readShort();
int file = copy.readUnsignedShort();
// decompress() starts reading here
int compression = copy.readUnsignedByte();
int compressedFileSize = copy.readInt();

View File

@@ -32,26 +32,31 @@ package net.runelite.cache.downloader.requests;
public class ConnectionInfo
{
private byte var1 = 3; // I don't know what this is
private int var2;
//login state of client
// 2 - logged in (in-game)
// 3 - logged out (not in-game)
private byte type = 3;
public byte getVar1()
//padding to make packet size == 4
private int padding;
public byte getType()
{
return var1;
return type;
}
public void setVar1(byte var1)
public void setType(byte type)
{
this.var1 = var1;
this.type = type;
}
public int getVar2()
public int getPadding()
{
return var2;
return padding;
}
public void setVar2(int var2)
public void setPadding(int padding)
{
this.var2 = var2;
this.padding = padding;
}
}

View File

@@ -35,7 +35,7 @@ public class HelloHandshake
public static final int RESPONSE_OK = 0;
public static final int RESPONSE_OUTDATED = 6;
private byte version = 15; // handshake type
private byte type = 15; // handshake type
private int revision;
public int getRevision()
@@ -47,14 +47,14 @@ public class HelloHandshake
{
this.revision = revision;
}
public byte getVersion()
public byte getType()
{
return version;
return type;
}
public void setVersion(byte version)
public void setType(byte type)
{
this.version = version;
this.type = type;
}
}