The 562 build of RuneScape was released on September 11, 2009.
Initial Connection Edit
When the client establishes a successful connection to the server, the client sends out a single byte which is the connection request id. There are many connection types, and each types tells the server what connection is being requested and what to write back to the client. Throughout the RuneScape client builds, most of these never change.
type = readUnsignedByte();
- Handshake: 15
- Game Login: 14
- JAGGRAB: 17
- Account Registration Information: 20
- Account Registration Username: 21
- Create an Account: 22
- World List Connection: 23
If the initial connection request was handshake, we proceed with handshake procedures. Next, the client sends out four bytes for the version build of the client. This is handled to make sure the connecting client is up-to-date with the server.
version = readInt();
Then the server writes back byte so we can proceed with the handshake procedure. There are many response id's the RuneScape client uses, but these are the one's used for handshake.
- Successful: 0
- Out of Date: 6
OnDemand (JS5) Edit
After the handshake response, next is the ondemand procedure. Next, the client will send out four bytes for the request side of ondemand.
id = readUnsignedByte();
There are many ondemand types in the client. For the sake of simplicity we will only show a few mainly used.
- Low File Prioirty: 0
- High File Prioirty: 1
- Logged Into Game: 2
- Not Logged Into Game: 3
Next we read the requested index.
index = readUnsignedByte();
Then we read the requested archive.
file = readUnsignedShort();
During the response, we actually read more information after you do some sort of cache validation. Depending on the requested index and file, we read an extra five bytes from the client.
compressed = readUnsignedByte();
uncompressed = readInt();
The only time you can't read this extra information is when the requested index equals 255 and the requested file also equals 255.
After this, we now write data back to the client during the ondemad procedure. First we write back the index as a byte.
Next the server writes the file back to the client as a short.
Then the server writes a mask. This mask is determined whether the request was a priority file. If the requested data was priority, then we use a bitwise operator on the compressed data.
settings |= 0x80;
And what we write to the client is a byte using that mask data.
Then we write to the client the uncompressed/length of the data.
After this, you write the rest of the data to the client. The sector length in all of RS2 builds is 512 bytes. When this threshold is met while writing data to the client, we also send another byte to the client as 255.