Skip to content

Clientside dataflow

Ben edited this page Oct 24, 2022 · 1 revision

Clientside dataflow

A brief explanation of way, data travels through the client.

After creating a client and letting it connect to a server, the IOHandler starts taking hand. The IOHandler is responsible for reading data from aswell as sending data to the server. I will divide this into two segments for easier explanation and understanding.

Outgoing traffic (Sending data)

Whenever you call client.send(byte[] data);, the passed data gets fed into the DataPreProcessor which will pass it through the processing-layers (if applicable) and based on them transformes the data (or simply passes the data through if no processing layers are present). After that, the data gets passed into the IOHandler, which finally sends the data to the server. This may look complicated and overengineered for now, but if you follow the wiki a little deeper down the rabbit hole, you will see that this allows for some pretty cool stuff, like for example encryption or data compression.

Understanding the incoming traffic (Receiving data)

Whenever the server sends data to the client, the data basically goes the opposite way of sending: the IOHandler reads it and passes it to the client.preprocessReceivedData(byte[] data); method, which in turn utilizes the DataPreProcessor, which does basically the same as with the outgoing traffic, if preprocessing layers are defined, otherwise it passes the data unaffected to the client.processReceivedData(byte[] data); method, where you can do whatever you like with it. Again, seems a little overengineered for now, but bear with me on the following chapters.