User picture
By Nathanroys on Mar 12, 2010 @ 12:49am UTC

AbstractTextFilter and some other updates

Today I have been busy, Iv'e added the AbstractTextFilter, this filters custom text depending on what you want to allow. Basically we have a few default sets in an enum type, here is that code.

public enum DefaultSet { LETTERS_ONLY, NUMBERS_ONLY, NUMBERS_AND_SYMBOLS, TEXT_AND_SYMBOLS, ALL_EXCEPT_ACSII, LETTERS_AND_NUMBERS };


They are all pretty self explanatory, to do a quick match of a word then you would use the method I have created especially for when you do not require using this as much as lets say, the username text filter.

AbstractTextFilter.quickMatch(new AllowedCharactersBuilder(LETTERS_ONLY), "Nathan");


This would return true, because I am checking if my string contains letters only which it does, this on the other hand:

AbstractTextFilter.quickMatch(new AllowedCharactersBuilder(LETTERS_ONLY), "Nathan2010");


would return false, because of the 2010 in there.

You can also add custom characters and strings into this. it's all in the java documentation which you may wish to read through, this update has been added to the SVN.

Other updates include: A message packet, server gets a message and then sends it out to all of the currently registered clients. Disconnection/De-Registering, now detects when this is done in an unfashionable way(clicked X or shutdown pc ect) or when the user clicks the logout button. They are both removed from the array when the current background tasks have finished parsing the list, stops any concurrent modification exceptions.

Thats it really, download the new SVN and that will be in there.

 
User picture
By Nathanroys on Mar 12, 2010 @ 12:41am UTC

PacketBuilder - Progress

Made the PacketBuilder base, this needs to be in info.hackersrus.common as it will be used by both client and server for packet sending receiving and also the encryption and decryption of packets. Once it is finished I will upload it to the formost directory as I mentioned.

At the moment the packet builder is simple, it constructs a ByteBuffer, I have created two different methods which are custom to the PackerBuilder class, these are putString, and putInt, they both return the PacketBuilder class for ease of use. Convention for sending the packet is basically as follows:

PacketBuilder.create(packetId).putString(Any values).toPacket().send();


I will be creating java documentation for this so it is easy to follow, at the moment I only have simple sending and recieving of ByteBuffer data over the non blocking connection, hopefully I will be able to expand on that tonight.

 
User picture
By Nathanroys on Mar 11, 2010 @ 12:22pm UTC

xSocket Scraped | New PacketBuilder Progress

I didn't like how xSocket was sending my packets, then ended up reading wrong serverside, so I have changed to the apache MINA networking libray, obviously it's just basically an easy NIO, it's pretty easy to use. Here is the **new** way to send a packet:

Please note: You must have the IoSesion to send the object over the socket, the Packet class is serialized so it can be sent and then deserialized at the client or server if need be.

So this is an example of the server requesting the login packet.

session.write(new PacketBuilder(1).create().putBoolean(true).toPacket());


The client would then respond with the following packet:
session.write(new PacketBuilder(1).create().putString("Username").putString("Password").toPacket());


Once the server has checked the SQL database and checked if the user exists and the password is correct, then it will use the login response packet.

session.write(new PacketBuilder().create().putBoolean(sucsessfulLogin ? true : false).putInt(returnCode).toPacket());


Please note, a return code is only needed if the login was **not** sucsessful.

I have managed to create an example client which I will upload to the SVN when I have time.