[Java] [Netty] [BoneCP] [Base] [Post-Shuffle] [Unique] Framework

Results 1 to 21 of 21
  1. #1
    Alpha Member Emily is offline
    MemberRank
    Oct 2012 Join Date
    The NetherlandsLocation
    2,408Posts

    [Java] [Netty] [BoneCP] [Base] [Post-Shuffle] [Unique] Framework

    Hello. Today I release a Framework for Java servers for Post-Shuffled SWF.
    This framework is unique due to one specific reason: It uses a special message handling with reflection Method except of implementing interface.

    Pros:
    - No need for 10000 classes, you can use 10 packets or more in 1 class.
    - It's something unique
    Cons:
    - I don't know if this is slower or not or if this is better or worse.

    It uses Netty for connection management and BoneCP for MySQL connection management.
    BoneCP is focused on Prepared Statements.
    It's completely from scratch.

    Link: Framework.rar

    Snippet:

    PHP Code:
    package framework.messages;

    import java.lang.reflect.Method;

    import framework.messages.requests.Handshake;
    import framework.sessions.Session;

    public class 
    MessageHandler {
        
        private 
    Method[] Packets;
        
        public 
    MessageHandler() {
            
    this.Packets = new Method[15000];
        }
        
        public 
    void AddPackets() throws Exception {
            
    this.Packets[6428] = Handshake.class.getMethod("CheckRevision"Session.class);
        }
        
        public 
    void HandleRequest(Session Sessionthrows Exception {
            
    Short Header Session.GetRequest().GetHeader();
            
            if (
    this.Packets[Header] != null)
                
    this.Packets[Header].invoke(this.Packets[Header], Session);
            else
                
    Session.Write(Header ": " Session.GetRequest().GetContent());
        }


    PHP Code:
    package framework.storage;

    import framework.Framework;

    import java.sql.Connection;
    import java.sql.PreparedStatement;
    import java.sql.ResultSet;
    import java.sql.SQLException;

    public class 
    DatabaseClient {

        private 
    String Query;
        private 
    Connection Connection;
        private 
    PreparedStatement Statement;
        private 
    Integer ParamCounter 1;

        public 
    void SetQuery(String Query) {
            
    this.Query Query;
            
            try {
                
    this.Connection Framework.GetDatabaseManager().GetBone().getConnection();
                
    this.Statement this.Connection.prepareStatement(this.Query);
            }
            catch (
    Exception ex) {
                
    System.out.println(ex.getMessage());
            }
        }
        
        public 
    void AddParameter(Object Valuethrows Exception {
            if (
    Value instanceof Integer) {
                
    this.Statement.setInt(this.ParamCounter++, (Integer)Value);
            }
            else if (
    Value instanceof String) {
                
    this.Statement.setString(this.ParamCounter++, (String)Value);
            }
            else if (
    Value instanceof Boolean) {
                
    this.Statement.setBoolean(this.ParamCounter++, (Boolean)Value);
            }
        }
        
        public 
    ResultSet GetTable() {
            try {
                return 
    this.Statement.executeQuery();
            } catch (
    SQLException e) {
                
    System.out.println(e.getMessage());
                return 
    null;
            }
        }
        
        public 
    ResultSet GetRow() {
            try {
                
    ResultSet set this.Statement.executeQuery();
                
                while (
    set.next())
                    return 
    set;
                
                return 
    set;
            } catch (
    SQLException e) {
                
    System.out.println(e.getMessage());
                return 
    null;
            }
        }
        
        public 
    Integer GetInteger() {
            try {
                
    ResultSet set this.Statement.executeQuery();
                return 
    set.getInt(0);
            } catch (
    SQLException e) {
                
    System.out.println(e.getMessage());
                return 
    null;
            }
        }
        

    Kind regards,

    Tha.


  2. #2
    Custom Title Enabled James is offline
    LegendRank
    Jan 2007 Join Date
    DenverLocation
    2,288Posts

    Re: [Java] [Netty] [BoneCP] [Base] [Post-Shuffle] [Unique] Framework

    Don't use reflection for packet handling, it's very heavy handed.


    It's cool you're trying to do something (sorta) different, but I'd honestly just store my MessageClasses and IDs inside of a dictionary, it's simple.

  3. #3
    Account Upgraded | Title Enabled! JaydenC is offline
    MemberRank
    Feb 2012 Join Date
    993Posts

    Re: [Java] [Netty] [BoneCP] [Base] [Post-Shuffle] [Unique] Framework

    Quote Originally Posted by James View Post
    Don't use reflection for packet handling, it's very heavy handed.


    It's cool you're trying to do something (sorta) different, but I'd honestly just store my MessageClasses and IDs inside of a dictionary, it's simple.
    I wouldn't agree..

    This framework would be for developers, easily adding packets + structures this way aswell. If you are going to use a dictionary you would be editing 5 different files, or atleast how bfly handles it.

  4. #4
    Ultra Light Beam Makarov is offline
    MemberRank
    Apr 2010 Join Date
    GothamLocation
    3,622Posts

    Re: [Java] [Netty] [BoneCP] [Base] [Post-Shuffle] [Unique] Framework

    Quote Originally Posted by jaydenn View Post
    I wouldn't agree..

    This framework would be for developers, easily adding packets + structures this way aswell. If you are going to use a dictionary you would be editing 5 different files, or atleast how bfly handles it.


    You are one smart cookie.

  5. #5
    Alpha Member Emily is offline
    MemberRank
    Oct 2012 Join Date
    The NetherlandsLocation
    2,408Posts

    Re: [Java] [Netty] [BoneCP] [Base] [Post-Shuffle] [Unique] Framework

    I'm already improving the framework..

    PHP Code:
    package framework.messages;

    import framework.messages.requests.handshake.CheckRevisionEvent;
    import framework.sessions.Session;
    import gnu.trove.map.hash.THashMap;

    public class 
    MessageHandler {
        
        private 
    THashMap<IntegerGameEventevents;
        
        public 
    MessageHandler() throws Exception {
            
    this.events = new THashMap<>();
            
            
    this.fillHandshake();
        }
        
        private 
    void fillHandshake() throws Exception {
            
    this.events.put(Opcodes.ReadRevisionComposer, new CheckRevisionEvent());
        }
        
        public 
    void HandleRequest(Session Sessionthrows Exception {
            
    Short Header Session.GetRequest().GetHeader();
            
            if (
    this.events.get(Header) != null)
                
    this.events.get(Header).RunGameEvent(Session);
            else
                
    Session.Write(Header ": " Session.GetRequest().GetContent());
        }


    Thanks to Master Cobe for example ^^

  6. #6
    "(still lacks brains)" NoBrain is offline
    MemberRank
    Sep 2011 Join Date
    United KingdomLocation
    2,658Posts

    Re: [Java] [Netty] [BoneCP] [Base] [Post-Shuffle] [Unique] Framework

    Whatever happened to Carbon?

  7. #7
    Alpha Member Emily is offline
    MemberRank
    Oct 2012 Join Date
    The NetherlandsLocation
    2,408Posts

    Re: [Java] [Netty] [BoneCP] [Base] [Post-Shuffle] [Unique] Framework

    Quote Originally Posted by ησвяαιη View Post
    Whatever happened to Carbon?
    I decided to change to Java, since Java is better because it's multi-platform plus I'm not good into stability and stability is easier in Java than in C#.

    Basically, this is Carbon now, I might finish the C# version someday too.

  8. #8
    Proficient Member Nathandj is offline
    MemberRank
    Jan 2012 Join Date
    The NetherlandsLocation
    194Posts

    Re: [Java] [Netty] [BoneCP] [Base] [Post-Shuffle] [Unique] Framework

    Quote Originally Posted by Tha View Post
    I decided to change to Java, since Java is better because it's multi-platform plus I'm not good into stability and stability is easier in Java than in C#.

    Basically, this is Carbon now, I might finish the C# version someday too.
    [You] [cant] [simply] [convert] [c#] [to] [java] .

  9. #9
    Alpha Member Emily is offline
    MemberRank
    Oct 2012 Join Date
    The NetherlandsLocation
    2,408Posts

    Re: [Java] [Netty] [BoneCP] [Base] [Post-Shuffle] [Unique] Framework

    Quote Originally Posted by Nathandj View Post
    [You] [cant] [simply] [convert] [c#] [to] [java] .
    Are you stupid or you just act like you are?
    Where did I told you I convert C# into Java? You're just saying that to look cool.

  10. #10
    The Legend Returns vista4life is offline
    MemberRank
    Mar 2007 Join Date
    The NetherlandsLocation
    843Posts

    Re: [Java] [Netty] [BoneCP] [Base] [Post-Shuffle] [Unique] Framework

    even when you code unstable in C# you get more trouble in java like the memory parts.. but o well everyone have hes own way Goodluck and thanks for a other framework release.

  11. #11
    Alpha Member Emily is offline
    MemberRank
    Oct 2012 Join Date
    The NetherlandsLocation
    2,408Posts

    Re: [Java] [Netty] [BoneCP] [Base] [Post-Shuffle] [Unique] Framework

    Quote Originally Posted by vista4life View Post
    even when you code unstable in C# you get more trouble in java like the memory parts.. but o well everyone have hes own way Goodluck and thanks for a other framework release.
    Thanks Maarten. But I got such a stress with stability in C# and I can't even get myself to learn lol. Thanks for your comment (oh lol, I just doubled-thanked you..)

  12. #12
    Developer Quackster is offline
    DeveloperRank
    Dec 2010 Join Date
    AustraliaLocation
    3,483Posts

    Re: [Java] [Netty] [BoneCP] [Base] [Post-Shuffle] [Unique] Framework

    Quote Originally Posted by Tha View Post
    I decided to change to Java, since Java is better because it's multi-platform plus I'm not good into stability and stability is easier in Java than in C#.

    Basically, this is Carbon now, I might finish the C# version someday too.
    Please make your mind up. You went from Java to C# and back to Java...

  13. #13
    Alpha Member Emily is offline
    MemberRank
    Oct 2012 Join Date
    The NetherlandsLocation
    2,408Posts

    Re: [Java] [Netty] [BoneCP] [Base] [Post-Shuffle] [Unique] Framework

    Quote Originally Posted by Quackster View Post
    Please make your mind up. You went from Java to C# and back to Java...
    Where did you get that information?
    My development thread clearly started with C#..

  14. #14
    Chasing 99 Red Balloons Jordan is offline
    MemberRank
    Jan 2008 Join Date
    UKLocation
    1,763Posts

    Re: [Java] [Netty] [BoneCP] [Base] [Post-Shuffle] [Unique] Framework

    Use a static map and a single MessageHandler for all clients, don't wrap BoneCP use it directly if you're using JSE 1.7 use a try block.

    PHP Code:
    try (Connection connection = ???.getConnection()) {
        try (
    PreparedStatement stmt connection.prepareStatement("blah")) {
            try (
    ResultSet results stmt.executeQuery()) {

             }
        }
    } catch (
    SQLException e) {



  15. #15
    Ultra Light Beam Makarov is offline
    MemberRank
    Apr 2010 Join Date
    GothamLocation
    3,622Posts

    Re: [Java] [Netty] [BoneCP] [Base] [Post-Shuffle] [Unique] Framework

    Quote Originally Posted by Jordan View Post
    Use a static map and a single MessageHandler for all clients, don't wrap BoneCP use it directly if you're using JSE 1.7 use a try block.

    PHP Code:
    try (Connection connection = ???.getConnection()) {
        try (
    PreparedStatement stmt connection.prepareStatement("blah")) {
            try (
    ResultSet results stmt.executeQuery()) {

             }
        }
    } catch (
    SQLException e) {


    I beat you to it bud.

  16. #16
    Alpha Member Emily is offline
    MemberRank
    Oct 2012 Join Date
    The NetherlandsLocation
    2,408Posts

    Re: [Java] [Netty] [BoneCP] [Base] [Post-Shuffle] [Unique] Framework

    I now do that:

    PHP Code:
    public static Habbo authenticate(String ssothrows Exception {
            
            try (
    Connection connection Framework.GetDatabaseManager().GetBone().getConnection())
            {
                try (
    PreparedStatement statement connection.prepareStatement("SELECT * FROM habbo_characters WHERE ssoticket = ?;"))
                {
                    
    statement.setString(1sso);

                    try (
    ResultSet set statement.executeQuery()) {
                        while (
    set.next()) {
                            
    Habbo Habbo = new Habbo(set);
                            
    Habbo.loadRest();
                            return 
    Habbo;
                        }
                    }
                }
                catch (
    Exception ex) {
                    
    ex.printStackTrace();
                }
            }
            catch (
    Exception ex) {
                
    ex.printStackTrace();
            }
            
            return 
    null;
        } 

  17. #17
    Alpha Member Caustik is offline
    MemberRank
    May 2011 Join Date
    LondonLocation
    1,837Posts

    Re: [Java] [Netty] [BoneCP] [Base] [Post-Shuffle] [Unique] Framework

    No need for:
    Code:
    throws Exception
    As you're testing a block for an exception inside the code.

    Quote Originally Posted by jaydenn View Post
    I wouldn't agree..

    This framework would be for developers, easily adding packets + structures this way aswell. If you are going to use a dictionary you would be editing 5 different files, or atleast how bfly handles it.
    So using heavy reflection instead of using a simple look up in a dictionary/map is better?
    Your stupidity amazes me...

  18. #18
    Alpha Member Emily is offline
    MemberRank
    Oct 2012 Join Date
    The NetherlandsLocation
    2,408Posts

    Re: [Java] [Netty] [BoneCP] [Base] [Post-Shuffle] [Unique] Framework

    Quote Originally Posted by Caustik View Post
    No need for:
    Code:
    throws Exception
    As you're testing a block for an exception inside the code.



    So using heavy reflection instead of using a simple look up in a dictionary/map is better?
    Your stupidity amazes me...
    First I didn't use prepared statements in this way, that's why I needed throws Exception. Forgot to remove it.

  19. #19
    are you ******* kidding!! capostrike93 is offline
    MemberRank
    Jan 2011 Join Date
    366Posts

    Re: [Java] [Netty] [BoneCP] [Base] [Post-Shuffle] [Unique] Framework

    Quote Originally Posted by James View Post
    Don't use reflection for packet handling, it's very heavy handed.


    It's cool you're trying to do something (sorta) different, but I'd honestly just store my MessageClasses and IDs inside of a dictionary, it's simple.

    Not really, if you load the functions from reflection only once (loading parsers when emulator starts storing the parsers in a static array..)

    Also is not really a good idea put all parsers in one class (maybe split into some class like "Messenger" "Rooms" etc..) anyways is more clean put every parser in a separated class (and for example java limit the ammount of code/functions in a class, idk if c# do the same..)

    ;)

  20. #20
    Alpha Member Emily is offline
    MemberRank
    Oct 2012 Join Date
    The NetherlandsLocation
    2,408Posts

    Re: [Java] [Netty] [BoneCP] [Base] [Post-Shuffle] [Unique] Framework

    Quote Originally Posted by capostrike93 View Post
    Not really, if you load the functions from reflection only once (loading parsers when emulator starts storing the parsers in a static array..)

    Also is not really a good idea put all parsers in one class (maybe split into some class like "Messenger" "Rooms" etc..) anyways is more clean put every parser in a separated class (and for example java limit the ammount of code/functions in a class, idk if c# do the same..)

    ;)
    I meant storing all the Character-events in Users.cs, all Handshake-events in Handshake.cs, but now I use something better (just every class implementing GameEvent with run function)

  21. #21
    Account Upgraded | Title Enabled! JaydenC is offline
    MemberRank
    Feb 2012 Join Date
    993Posts

    Re: [Java] [Netty] [BoneCP] [Base] [Post-Shuffle] [Unique] Framework

    Quote Originally Posted by Caustik View Post
    No need for:
    Code:
    throws Exception
    As you're testing a block for an exception inside the code.



    So using heavy reflection instead of using a simple look up in a dictionary/map is better?
    Your stupidity amazes me...
    no need to call me stupid.

    its more effective, less functional though..



Advertisement