Well a simple update/key sending server is real easy to do.
Here is some example code from a 474 rs2hd server.
When the connection has been recieved you have to check for a byte 15 instead of 14(Case 0 of the example below). If it was a 15 then the case -1 is called when more data is recieved, then -2.
Code:
switch (loginStage) {
case -2:
if (8 <= in.remaining()) {
for (int i = 0; i < 8; i++) {
in.get();
}
StaticPacketBuilder ukeys = new StaticPacketBuilder();
ukeys.setBare(true);
for (int key : Constants.UPDATE_KEYS) {
ukeys.addByte((byte) key);
}
session.write(ukeys.toPacket());
session.close();
return true;
}
in.rewind();
return false;
case -1:
if (3 <= in.remaining()) {
in.get();
int clientVersion = in.getShort();
if (clientVersion == 474) {
StaticPacketBuilder u1Response = new StaticPacketBuilder();
u1Response.setBare(true).addByte((byte) 0);
session.write(u1Response.toPacket());
session.setAttribute("LOGIN_STAGE", -2);
}
return true;
}
in.rewind();
return false;
case 0: // first login packets
if (2 <= in.remaining()) {
int protocolId = in.get() & 0xff;
@SuppressWarnings("unused")
int namePart = in.get() & 0xff;
if (protocolId == 15) {
session.setAttribute("LOGIN_STAGE", -1);
} else {
long serverSessionKey = ((long) (java.lang.Math
.random() * 99999999D) << 32)
+ (long) (java.lang.Math.random() * 99999999D);
StaticPacketBuilder s1Response = new StaticPacketBuilder();
s1Response.setBare(true).addByte((byte) 0).addLong(
serverSessionKey);
session.setAttribute("SERVER_SESSION_KEY",
serverSessionKey);
session.write(s1Response.toPacket());
session.setAttribute("LOGIN_STAGE", 1);
// Logger.log("protocolId="+protocolId+"; namePart="+namePart);
}
return true;
} else {
in.rewind();
return false;
}