Packet 3 (Focus Change)
Well many of you might have no idea what this packet is used for. Well I will inform you what it is and show you some possible ways of using it.
The main thing it is used for is checking the focus of the user. For example if the player clicks away from the client it sends a focus change stream to the server and when the player clicks back on the client it sends another focus change stream.
This is great way to detect cheating or other possible client hacks.
For example lets say someone connects to your server. By default you would have set the server to have the setting of true for focus when upon joining the server.
So this would be in your client.java;
Code:
private boolean focus = true;
It would be set to true because the character would not be able to send a focus packet when logged out.
After that you would want to make it change whenever a user clicks off the client and back onto it.
So you would change packet 3 (Focus change packet) to;
Code:
focus = !focus;
//System.out.println("Focus changed");
Now all what you would have to do is create a method to check if the focus is true whenever someone try's to send a packet.
For example you might make this method;
Code:
public boolean checkActivity() {
return active;
}
And then you would add into your other packets which can ONLY be sent when your client focus is set to true.
For example you would put at the top of packet 103;
Code:
if(!checkActivity())
return;
That would check if the player has a valid focus to send the packet. If the player doesn't meet the requirements it just returns and stops the packet from being executed.
The above information can really help you and your server out against so-called cheat client's and other hacks (I know ViperSniper's cheatclient could send Object Clicks' over and over with the window minimized).
Well I hoped this information helped someone.