Results 1 to 7 of 7
  1. #1
    ♪~ ᕕ(ᐛ)ᕗ's Avatar
    Join Date
    Jun 2010
    Gender
    male
    Location
    Uterus
    Posts
    9,119
    Reputation
    1096
    Thanks
    1,970
    My Mood
    Doh

    SlotMachine v1.0

    1.What is SlotMachine?
    SlotMachine is a library designed in about 5 minutes to group your applications classes. This feature is commonly used in network servers when you have to create a room for every incoming client. (More examples below)


    2.How to use this?
    First of all you have to add it as a reference to your application and then: -Chatting Application Example-
    Mark your desired group-type class as a Slot
    Code:
    public class ChatRoom : Slot
    {
       private void PutRoomOnline();
       private void PutRoomOffline();
    
       public ChatRoom(long ID) : base(ID) { };
    
       public override void StartSlot()
       {
             PutRoomOnline(); //This might need a new Thread.
       }
    
       public override void StopSlot()
       {
            PutRoomOffline();
       }
    }
    Once you're done with this you can proceed to the Master Server's code:
    Code:
    public class ChattingServer : SlotMachine
    {
          private string ReceiveStringMessage(out Socket sender);
    
          public ChattingServer() : base()
          {
               //Define more things if you want
          }
    
          public void RunServer()
          {
                 Socket s;
                 string msg = ReceiveStringMessage(out s);
    
                 if(msg == "/createRoom -id 5587 -name 'Elio'")
                 {
                       ChatRoom room = new ChatRoom(5587);
                       this.RegisterSlot(room, "Elio");
                 }
    
                 if(msg == "/startRoom -name 'Elio'")
                 {
                       this.StartSlot("Elio", true);
                 }
          }
    }

    Now this was just a little piece of example of what you can actually do with this, just use your brain and start developing well-coded applications.



    SOURCE CODE:
    Code:
    //FILE NAME: Slot.cs
    //Creator: Elio Decolli (Richard Nixon)
    //- MPGH 2012
    
    
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    
    namespace SlotMachine
    {
        /// <summary>
        /// Represents a Slot class. This class must serve as a base.
        /// </summary>
        [Serializable]
        public abstract class Slot
        {
            long ID = 0x00000000000L;
    
            public Slot(long slotID)
            {
                ID += slotID;
            }
    
            /// <summary>
            /// Gets the current Slot ID.
            /// </summary>
            public long SlotID { get { return ID; } }
    
            /// <summary>
            /// Starts the current Slot.
            /// </summary>
            public void StartSlot()
            {
            }
    
            /// <summary>
            /// Stops the current Slot.
            /// </summary>
            public void StopSlot()
            {
            }
        }
    }
    Code:
    //FILE NAME: SlotMachine.cs
    //Creator: Elio Decolli (Richard Nixon)
    //- MPGH 2012
    
    
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Threading;
    
    namespace SlotMachine
    {
        /// <summary>
        /// Represents a Slot Machine class, used to store and manage slots.
        /// </summary>
        [Serializable]
        public class SlotMachine
        {
            private Dictionary<string, Slot> PPES = new Dictionary<string, Slot>();
    
            public SlotMachine()
            {
            }
    
            /// <summary>
            /// Adds a new Slot to the Slot Machine.
            /// </summary>
            /// <param name="slot">The Slot to be added.</param>
            /// <param name="name">The UNIQUE name of the Slot.</param>
            public void RegisterSlot(Slot slot, string name)
            {
                if (PPES.ContainsKey(name))
                {
                    throw new Exception("Slot Name is already taken.");
                }
                PPES.Add(name, slot);
            }
    
            /// <summary>
            /// Removes a Slot from the storage.
            /// </summary>
            /// <param name="name">The unique name of the Slot to be removed.</param>
            public void RemoveSlot(string name)
            {
                if (!PPES.ContainsKey(name))
                {
                    throw new Exception("Slot Name doesn't exists in the current contest.");
                }
                PPES.Remove(name);
            }
    
            /// <summary>
            /// Removes a Slot from the storage.
            /// </summary>
            /// <param name="slot">The Slot to be removed.</param>
            public void RemoveSlot(Slot slot)
            {
                if (!PPES.ContainsValue(slot))
                {
                    throw new Exception("Slot doesn't exists in the current contest.");
                }
                foreach (KeyValuePair<string, Slot> kp in PPES)
                {
                    if (kp.Value == slot)
                        PPES.Remove(kp.Key);
                }
            }
    
            /// <summary>
            /// Starts a Slot from the storage.
            /// </summary>
            /// <param name="name">The name of the Slot to start.</param>
            /// <param name="createNewThread">If True the Slot will be runned in a new thread, otherwise not.
            /// Warning: Once you start a Slot in a new thread you cannot stop it, unless you find and close that thread.</param>
            public void StartSlot(string name, bool createNewThread)
            {
                if (createNewThread)
                {
                    Thread t = new Thread(PPES[name].StartSlot);
                    t.Start();
                }
                else
                {
                    PPES[name].StartSlot();
                }
            }
        }
    }
    SlotMachine.rar - Jotti's malware scan
    https://www.virustotal.com/file/ee49...is/1342296814/

    @Thunder, @Disturbed, @Liz Approve ?
    <b>Downloadable Files</b> Downloadable Files
    Last edited by ♪~ ᕕ(ᐛ)ᕗ; 07-14-2012 at 03:32 PM.

  2. The Following 2 Users Say Thank You to ♪~ ᕕ(ᐛ)ᕗ For This Useful Post:

    JeremyKyle (09-03-2014),kahn520 (07-31-2012)

  3. #2
    Hassan's Avatar
    Join Date
    May 2010
    Gender
    male
    Location
    System.Threading.Tasks
    Posts
    4,764
    Reputation
    495
    Thanks
    2,133
    My Mood
    Dead
    Approved.

  4. #3
    ♪~ ᕕ(ᐛ)ᕗ's Avatar
    Join Date
    Jun 2010
    Gender
    male
    Location
    Uterus
    Posts
    9,119
    Reputation
    1096
    Thanks
    1,970
    My Mood
    Doh
    Quote Originally Posted by Hassan View Post
    Approved.
    lmao. Fail, I tho this section had a minion? :/

    PS: Nigga be trollin me

  5. #4
    Liz's Avatar
    Join Date
    Feb 2009
    Gender
    female
    Location
    179° 56′ 39.4″, +0° 2′ 46.2″, 7,940 ± 420 parsecs
    Posts
    37,181
    Reputation
    5621
    Thanks
    20,746
    My Mood
    Tired
    [IMG]https://i423.photobucke*****m/albums/pp312/LizMLsinatra/retard_dog.jpg[/IMG]

    And so do I.

    If anyone claims to be me via any other source outside of MPGH private or visitor messages, IT'S NOT ME!
    They are trying to trick or scam you. Report them immediately and PM me here for verification.
    "Don’t confuse my personality with my attitude. My personality is who I am. My attitude depends on who you are." — Frank Ocean
    Moderator: 5/2009-10/2009 | GMod: 10/2009-10/2010 | Staff Administrator: 10/2010-Present
    I
    do not do requests via PM. Post in the appropriate section.
     
    Stupid/Pointless Private messages = SPAM, SPAM = BAN.

  6. The Following User Says Thank You to Liz For This Useful Post:

    ♪~ ᕕ(ᐛ)ᕗ (07-15-2012)

  7. #5
    ♪~ ᕕ(ᐛ)ᕗ's Avatar
    Join Date
    Jun 2010
    Gender
    male
    Location
    Uterus
    Posts
    9,119
    Reputation
    1096
    Thanks
    1,970
    My Mood
    Doh
    Quote Originally Posted by Liz View Post
    [IMG]https://i423.photobucke*****m/albums/pp312/LizMLsinatra/retard_dog.jpg[/IMG]

    And so do I.
    Thank you retard dog.

  8. #6
    Hassan's Avatar
    Join Date
    May 2010
    Gender
    male
    Location
    System.Threading.Tasks
    Posts
    4,764
    Reputation
    495
    Thanks
    2,133
    My Mood
    Dead
    Quote Originally Posted by Richard Nixon View Post


    Thank you retard dog.
    Lol...fail ! The file was already approved by the time I got your mention.

  9. #7
    ♪~ ᕕ(ᐛ)ᕗ's Avatar
    Join Date
    Jun 2010
    Gender
    male
    Location
    Uterus
    Posts
    9,119
    Reputation
    1096
    Thanks
    1,970
    My Mood
    Doh
    Quote Originally Posted by Hassan View Post


    Lol...fail ! The file was already approved by the time I got your mention.
    Nope.avi it said "Attachments pending approval."