public void run(){
        //Read input and process here
        mainServer.log("Client connecting from " + address);
        //DataOutputStream out = null;
        try {
            in = new BufferedReader(new InputStreamReader(socket.getInputStream()));
            out = new PrintWriter(socket.getOutputStream(), true);

        } catch (Exception e) {
            e.printStackTrace();
            mainServer.log("Failed to get input or output stream from " + address);
            connected = false;
            this.close();
        }
        if(connected) {
            mainServer.log("Client connected. (" + address + ")");
            sendData(clientVersion + "");
            mainServer.senDataToAll(clientManager, "{103}" + clientManager.onlineUserList());
        }
        String rec;
        while(connected){
            try {
                rec = in.readLine();
                if(rec == null) {connected = false; break;}
                if(rec.isEmpty()) break;
                commandReturn recieved = commandHandler.findCommand(rec);

                switch(recieved.TYPE){
                    case MESSAGE:
                        mainServer.sendMsgToAll(this, clientManager, recieved.message);
                        break;
                    case LOGIN:
                        this.email = recieved.message;
                        //sendData("Logged in as " + this.email);
                        mainServer.log(this.address + ": Logged in with " + this.email);
                        mainServer.sendMsgToAll(this, clientManager, "Connected to the server");
                        mainServer.senDataToAll(clientManager, "{101}" + this.email);
                        break;
                    case PING:
                        break;
                }
            } catch (IOException e) {
                //e.printStackTrace();
                connected = false;
            }

        }
        close();
    }