Carbon - R63 Post-Shuffle - C# - Weak Cache - Own Database - .NET 4.0

Page 1 of 13 12345678911 ... LastLast
Results 1 to 15 of 182
  1. #1
    Alpha Member Emily is offline
    MemberRank
    Oct 2012 Join Date
    The NetherlandsLocation
    2,408Posts

    Carbon - R63 Post-Shuffle - C# - Weak Cache - Own Database - .NET 4.0

    Hi I am making a emulator from scratch
    It uses Fluent NHibernate mapping and Socket Async Event Args (SAEA)
    I lost my other source because my laptop 'died', so I had to start over.
    It runs on RELEASE63-201301231323-316947488 (post-shuffle SWF)
    It will be finished (backupped on Dropbox, link won't be shared!)
    I will definitely opload it on Github sometimes, but first I need to finish more.
    It can be used with Visual Studios 2010 (just saying because for people like me who hate the GUI of Visual Studios 2011/2012)

    Snippets:

    BotsMapping.cs:
    PHP Code:
    public class BotsMapping ClassMap<Bots>
        {
            public 
    BotsMapping()
            {
                
    base.Table("bots");
                
    base.LazyLoad();
                
    base.Id().GeneratedBy.Identity().Column("id");
                
    base.Map(=> x.RoomID).Column("room_id");
                
    base.Map(=> x.Name).Column("name");
                
    base.Map(=> x.Motto).Column("motto");
                
    base.Map(=> x.Look).Column("look");
                
    base.Map(=> x.X).Column("x");
                
    base.Map(=> x.Y).Column("y");
                
    base.Map(=> x.Z).Column("z");
                
    base.Map(=> x.Rotation).Column("rotation");
                
    base.Map(=> x.MinX).Column("min_x");
                
    base.Map(=> x.MaxX).Column("max_x");
                
    base.Map(=> x.MinY).Column("min_y");
                
    base.Map(=> x.MaxY).Column("max_y");
                
    base.Map(=> x.Walk).Column("walk_mode");
            }
        } 
    Create ISessionFactory:
    PHP Code:
            private static ISessionFactory CreateSessionFactory()
            {
                return 
    Fluently.Configure()
                    .
    Database(MySQLConfiguration.Standard.ConnectionString(ConnectionString))
                    .
    Mappings(=> m.FluentMappings.AddFromAssemblyOf<UserMap>())
                    .
    BuildSessionFactory();
            } 
    What I (will) cache in the beginning:
    - Navigator frontpage items ('public' room listing and campaign winned rooms)
    - Vouchers
    - Catalogue pages (No items and no base items)

    When getting an user from ID, it checks if the id is in the dictionary. If not, will get the user from sql and insert the ID in dictionary. Otherwise, get user from dictionary. If an user is already connected, the id is already in dictionary.

    What I mean:
    CharacterManager:
    PHP Code:
     public class CharacterManager
        
    {
            private 
    IDictionary<intUser_characters;

            public 
    CharacterManager()
            {
                
    this._characters = new Dictionary<intUser>();
            }

            public 
    bool TryAuthenticateUser(string SSOout User User)
            {
                try
                {
                    
    User Application.Session.CreateCriteria<User>().Add(Restrictions.Eq("Auth_Ticket"SSO)).UniqueResult<User>();

                    if (!
    _characters.ContainsKey(User.Id))
                        
    _characters.Add(User.IdUser);

                    return 
    true;
                }
                catch
                {
                    
    User null;
                    return 
    false;
                }
            }

            public 
    void GetUser(int Idout User User)
            {
                if (
    _characters.ContainsKey(Id))
                {
                    
    User _characters[Id];
                }
                else
                {
                    try
                    {
                        
    User Application.Session.Get<User>(Id);

                        if (!
    _characters.ContainsKey(User.Id))
                            
    _characters.Add(User.IdUser);
                    }
                    catch
                    {
                        
    User null;
                    }
                }
            } 
    (offcourse this contains the namespace and using things, just cba to add them:P)

    Screens:
    Spoiler:






    Credits:
    Tha (AKA me) - Coding the components and packets
    Jagregory - Fluent NHibernate
    Habbolatino - Some packet ID comparing
    Droppy - Helping me in previous stages + supporting
    vista4life - Helping me a few times
    Last edited by Emily; 04-02-13 at 04:31 PM. Reason: Updated thread


  2. #2
    Account Upgraded | Title Enabled! Kristopher is offline
    MemberRank
    Sep 2011 Join Date
    266Posts

    Re: Carbon - R63 Post-Shuffle - C# - Weak Cache - Own Database - .NET 4.0

    Good luck with the project. Hope you finish this! Any other features? You didnt say much.

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

    Re: Carbon - R63 Post-Shuffle - C# - Weak Cache - Own Database - .NET 4.0

    Good luck on your project, actually finish one this time :P

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

    Re: Carbon - R63 Post-Shuffle - C# - Weak Cache - Own Database - .NET 4.0

    Quote Originally Posted by Kristopher View Post
    Good luck with the project. Hope you finish this! Any other features? You didnt say much.
    Worked on subscription manager a bit, console loading friends on login. Fully initialized hotelview (splitted by DateTime soon). Group information is done and group members almost.

    Gonna work on navigator and catalog today, but want to do some Weak Caching modules.

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

    Re: Carbon - R63 Post-Shuffle - C# - Weak Cache - Own Database - .NET 4.0

    Your "WeakRoomCache" shows no sign of using weak references....

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

    Re: Carbon - R63 Post-Shuffle - C# - Weak Cache - Own Database - .NET 4.0

    Quote Originally Posted by Jordan View Post
    Your "WeakRoomCache" shows no sign of using weak references....
    It's the first version of the code, already planned to update it.
    No worries :)

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

    Re: Carbon - R63 Post-Shuffle - C# - Weak Cache - Own Database - .NET 4.0

    WeakReference Class (System)
    This may help with the weak reference stuff.

    Also "supersockets" is a library, which I don't think was used in HE2

  8. #8
    Alpha Member Zak© is offline
    MemberRank
    Oct 2007 Join Date
    2,693Posts

    Re: Carbon - R63 Post-Shuffle - C# - Weak Cache - Own Database - .NET 4.0

    Quote Originally Posted by Caustik View Post
    WeakReference Class (System)
    This may help with the weak reference stuff.

    Also "supersockets" is a library, which I don't think was used in HE2
    Yeah its a wrapper of the .NET library nothing different i guess but its unique features like its AppSession and Server functions.

    I don't see why you keep calling rows in each packets it is not needed, just make a class containing all the user data and then make a Session class where you can get this data and link that Session to each packet.

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

    Re: Carbon - R63 Post-Shuffle - C# - Weak Cache - Own Database - .NET 4.0

    Quote Originally Posted by Caustik View Post
    WeakReference Class (System)
    This may help with the weak reference stuff.

    Also "supersockets" is a library, which I don't think was used in HE2
    About the WeakReference class, I found that a short while ago but thanks anyway.
    And I use to call SAEA supersockets for some reason, so I keep on calling it, IDK why.

    POST ADDED 30-12-2012 18:10
    @Zak Yes I know, don't know why I did it. I'm creating the class now.
    Last edited by Emily; 30-12-12 at 06:10 PM.

  10. #10
    Occasional Visitor Cecer is offline
    MemberRank
    Aug 2006 Join Date
    EnglandLocation
    743Posts

    Re: Carbon - R63 Post-Shuffle - C# - Weak Cache - Own Database - .NET 4.0

    This might be useful to you.
    https://github.com/Cecer1/Bluedot/bl...g/WeakCache.cs

    You are free to use any and all of my Bluedot code. Credits are not required (as I am not an egomania infested arsehole) but are appreciated as a sign of gratitude.

    Here is an simple example on how to use it:
    PHP Code:
    public WeakCache<intRoomWeakRoomCache = new WeakCache<intHabbo>(LoadRoom);

    private 
    Room LoadRoom(int id)
    {
        
    DataRow row /*<However you want to load the room data here*/;
        
        return new 
    Room(row);

    You can access it like this:
    PHP Code:
    Room someRoom SomeClass.WeakRoomCache[/*roomIdHere*/]; 
    If the room is not loaded then it will be loaded and cached automatically.

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

    Re: Carbon - R63 Post-Shuffle - C# - Weak Cache - Own Database - .NET 4.0

    Quote Originally Posted by cecer1 View Post
    This might be useful to you.
    https://github.com/Cecer1/Bluedot/bl...g/WeakCache.cs

    You are free to use any and all of my Bluedot code. Credits are not required (as I am not an egomania infested arsehole) but are appreciated as a sign of gratitude.

    Here is an simple example on how to use it:
    PHP Code:
    public WeakCache<intRoomWeakRoomCache = new WeakCache<intHabbo>(LoadRoom);

    private 
    Room LoadRoom(int id)
    {
        
    DataRow row /*<However you want to load the room data here*/;
        
        return new 
    Room(row);

    You can access it like this:
    PHP Code:
    Room someRoom SomeClass.WeakRoomCache[/*roomIdHere*/]; 
    If the room is not loaded then it will be loaded and cached automatically.
    Off course I will give credits, but I forgot to add credits I already had to add so will do that in a few hours, but for now I'm going to play some black ops 2 zombies so I'm not working on emulator.

    Thanks cecer for your help, much appreciated.

  12. #12
    Occasional Visitor Cecer is offline
    MemberRank
    Aug 2006 Join Date
    EnglandLocation
    743Posts

    Re: Carbon - R63 Post-Shuffle - C# - Weak Cache - Own Database - .NET 4.0

    I just noticed that I didn't link you to all the required files.
    You'll want this too: https://github.com/Cecer1/Bluedot/bl...kDictionary.cs

    Edit: I just noticed WeakCache was outdated and have just updated it. Instead of the WeakDictionary above you need to use the more flexible (and messy) BluedotDictionary.

    https://github.com/Cecer1/Bluedot/bl...tDictionary.cs
    Last edited by Cecer; 30-12-12 at 07:18 PM.

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

    Re: Carbon - R63 Post-Shuffle - C# - Weak Cache - Own Database - .NET 4.0

    Bug Fixed.

    Working on catalog. Now retrieves the index correctly.
    Working on the other incoming packets and the catalog pages.
    Last edited by Emily; 30-12-12 at 10:05 PM.

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

    Re: Carbon - R63 Post-Shuffle - C# - Weak Cache - Own Database - .NET 4.0

    Coded much more things:

    Messenger is almost fully coded EXCLUDING offline chat and mute chat check, only online and is friend check, also following doesn't work yet.




    The friendbar notification needs to be figured out with the extra string sent in the composer, will find that out (I know for example if the user unlocks an achievement it will give the badge name).

    Now working a bit more on catalog, making for example the items and maybe some other things.

  15. #15
    j’aime ma famille dominic is offline
    MemberRank
    Aug 2012 Join Date
    ~/Location
    611Posts

    Re: Carbon - R63 Post-Shuffle - C# - Weak Cache - Own Database - .NET 4.0

    The RowAdapter class was initially made by MrSolution / Wichard. It is to find in Tazqon.



Page 1 of 13 12345678911 ... LastLast

Advertisement