public void run() {
        while (true) {
            // Load the packet from a client.
            NameServerPacket packet = null;
            try {
                packet = (NameServerPacket) this.client.inStream.readObject();
            } catch (IOException e) {
                System.out.println("Removing client from the active client pool.");
                server.activeClients.remove(client);
                e.printStackTrace();
            } catch (ClassNotFoundException e) {
                e.printStackTrace();
            }

            System.out.println("##################################################");
            System.out.println("Got " + packet.toString() + " packet from client " + this.client.id);

            NameServerPacket outPacket = new NameServerPacket();
            switch (packet.type){
                case NameServerPacket.TYPE_REGISTER:
                    server.addToActiveClients(this.client);

                    outPacket.type = NameServerPacket.TYPE_REGISTER;
                    outPacket.id = this.client.id;
                    // Give the socket details for the preceeding client.

                    break;
                case NameServerPacket.TYPE_GET_CLIENTS:
                    outPacket.type = NameServerPacket.TYPE_GET_CLIENTS;
                    outPacket.id = this.client.id;

                    ArrayList<ClientConnectionInfo> clients = new ArrayList<ClientConnectionInfo>();

                    for (NameServerClient obj : server.activeClients) {
                        clients.add(obj.getClientConnectionInfo());
                    }

                    outPacket.clients = clients;
                    break;
                case NameServerPacket.TYPE_GET_SEQUENCE_NUMBER:
                    outPacket.type = NameServerPacket.TYPE_GET_SEQUENCE_NUMBER;
                    outPacket.id = this.client.id;
                    // Give the socket details for the preceeding client.
                    outPacket.sequenceNo = server.getSequenceNumber();
                    break;
            }

            System.out.println("Sending " + outPacket.toString() + " packet to client " + this.client.id);
            System.out.println("##################################################");

            try {
                this.client.outStream.writeObject(outPacket);
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }