Alright, well, I got done most of what I planned to. The work I planned on getting done was to get all of the Java code set up for creating our own custom login and sign up for our game. This will be exciting once fully done and is one of the larger requirements. What I finished tonight was database related data classes and SmartFox configuration for login and signup.
There are several classes that I added to our game that are meant to serve a small purpose. The purpose of these classes are to be direct relations to the tables we will be querying on our database. I did this so that we would have an efficient, easy to implement, way to store objects in memory when they are needed. Hopefully this will reduce the number of queries we will need by not hitting the database as much. Really, this is the only reason I did this. The classes are simple, private members that reflect data on the database, some different constructors, and setters and getters. They have zero functionality, again, serving only as data containers.
The SmartFox code was simple and easy to put in. I simply added it to our Extension class. I followed some tutorials that were out there and I was able to add it all in with no hitch. No hitch, mostly because I need to have a database set up before I can test it. The code, for Starbound Aces needs, is as follows:
private void login(){
login = new LoginAssistantComponent(this);
login.getConfig().loginTable = "sa_user";
login.getConfig().userNameField = "user_name";
login.getConfig().passwordField = "user_password";
login.getConfig().useCaseSensitiveNameChecks = true;
login.getConfig().activationField = "user_state";
login.getConfig().activationErrorMessage =
"Your account is not yet activated. "+
"Please check you inbox for the confirmation email";
login.getConfig().postProcessPlugin = new LoginAssistantPlugin();
}
Above you can see that the method is made for handling the login request calls. This will be used for logging in players who have set up username accounts. We will also allow guests to log in as an option client side. The LoginAssistantPlugin is a private class implementing the interface with the same name (with a prefixing I).
It does nothing right now and is of no importance at the moment.
private void signUp(){
signup = new SignUpAssistantComponent();
signup.getConfig().signUpTable = "sa_user";
signup.getConfig().minUserNameLength = 4;
signup.getConfig().maxUserNameLength = 64;
signup.getConfig().minPasswordLength = 8;
signup.getConfig().maxPasswordLength = 64;
signup.getConfig().userIsActiveField = "user_state";
signup.getConfig().activationCodeField = "user_activation_code";
signup.getConfig().logSQL = true;
signup.getConfig().emailResponse.isActive = true;
signup.getConfig().emailResponse.fromAddress = "signup@starboundaces.com";
signup.getConfig().emailResponse.subject = "It is time for you to begin your adventure.";
signup.getConfig().emailResponse.template = "SignUpEmailTemplates/SignUpConfirmation.html";
signup.getConfig().preProcessPlugin = new SignUpAssistantPlugin();
addRequestHandler(SignUpAssistantComponent.COMMAND_PREFIX, signup);
}
The signup method is a little bit longer. But from the configuration you can see that we have a table name, some requirements, and email confirmation. SmartFox handles a lot of this for us (thankfully) so we merely need to configure it. Unlike the login component, the sign up component needs to be added as a RequestHandler in the extension. To note, login and signup are private classes in the Extension class. SignUpAssistantPlugin is an implementation of the SmartFox interface of the same name (prefixed with an I) and does nothing at the moment.
So far I am a third of the way done. To finish this requirement I need to add the database tables to our server and implement the client interface for signing up and registering.
Until next time, enjoy your own game programming and have a good day!
No comments:
Post a Comment