Gamma 1.0 - r63 [Java Emulator, Multithreaded]

Status
Not open for further replies.

Quackster

a devbest user says what
Aug 22, 2010
1,764
1,241
Gamma

The section get's shitty after a while from seeing so much customs, cms and C# releases. So I decided to add in a little bit of spice by creating a multi-threaded JAVA server. It doesn't use Netty at all or any other addons.

Please read this important note:

Gamma is unfinished, do not use it for a hotel. It is only for educational purposes. Please do not ask for help in this thread or how to open it.

Features


  • Hardcoded packet handling (thaaa best feature evarrr)
  • Thread manager.
  • Allows one ip per connection
  • Multi-threaded

How does it work?

Well it's simple. Every time there is a new connection, a new thread is created to handle it. This allows multi-tasking when handling clients.

How do I change the port?

Go to environment.java and you'll see where to change it.

Can we see some code?

Code:
package gamma.threading;

import gamma.main.Environment;


import java.net.Socket;
import java.util.HashMap;
import java.util.Map;


public class GammaThreadManager
{
    private Map<String, GammaThread> Clients;
    private Map<GammaThread, Thread> Threads;
    
    public GammaThreadManager()
    {
        this.Clients = new HashMap<String, GammaThread>();
        this.Threads = new HashMap<GammaThread, Thread>();
    }
    
    public void AcceptClient(Socket Client)
    {
        /*
         * Get existing thread if possible
         */
        GammaThread _existingThread = Clients.get(this.getIp(Client));
        
        /*
         * Check for existing ip address and dispose them
         */
        if (_existingThread != null)
        {
            /*
             * Stop thread.
             */
            Clients.get(this.getIp(Client)).Disposed = true;
            Threads.get(_existingThread).interrupt();
            
            /*
             * Remove both
             */
            Clients.remove(this.getIp(Client));
            Threads.remove(_existingThread);
        }
        
        /*
         * Add client to map.
         */
        GammaThread _gThread = new GammaThread(Client);
        
        this.Clients.put(this.getIp(Client), _gThread);
        
        /*
         * Add new thread to map.
         */
        this.Threads.put(_gThread, new Thread(_gThread));
        
        /*
         * Start thread.
         */
        this.Threads.get(_gThread).start();
    }
    
    public String getIp(Socket Socket)
    {
        return Socket.getLocalAddress().toString().replace("/", "");
    }
}

A picture

8886284267.png





 

brsy

nah mang
May 12, 2011
1,530
272
Sooooo many emulators you've made... why not stick to one? Anyway looks decent, keep up the good work.
 

Rogen

Coldfusion Developer
Jul 21, 2012
17
1
So many good releases, so many good emulators from you Quackster.
 
Status
Not open for further replies.

Users who are viewing this thread

Top