package mafiaserver;

/**
 * ServerClientConnector.java
 * Contains the server client connector class
 * @author Cory Gehr (cmg5573)
 */
public class ServerClientConnector extends Thread {
    
    private final MafiaServer serverObject; // MafiaServer object
    private final Participant client;    // The client we're connected to
    
    /**
     * ServerClientConnector()
     * Constructor for the ServerClientConnector class
     * @param client Participant object
     * @param serverObject IMServer Object
     */
    public ServerClientConnector(Participant client, MafiaServer serverObject) {
        this.client = client;
        this.serverObject = serverObject;
    }
    
    /**
     * run()
     * Main thread execution procedures
     */
    @Override
    public void run() {
        while(true) {
            // Wait for a message from the participant
            this.parseInput(client.getInput());
        }
    }
    
    /**
     * parseInput()
     * Determines an action to perform based on user input
     * @param input User Input
     */
    public void parseInput(String input) {
        // Separator string
        String separator = "---------------";
        // input Cases
        switch(input) {
            case "SHOW USERS":
                client.pushOutput(separator);
                client.pushOutput("CURRENTLY CONNECTED USERS:");
                client.pushOutput(separator);
                client.pushOutput(this.serverObject.getClientList());
            break;
            
            default:
                // Broadcast message
                ServerMessageBroadcaster broadcast = 
                        new ServerMessageBroadcaster(this.client, 
                                this.serverObject.clients, input);
                broadcast.start();
            break;
        }
    }
}

@@ -1212,41 +1212,24 @@
     
-switch(input) %7B%0A            case 
+if(input.equals(
 %22SHO
@@ -1236,22 +1236,21 @@
 W USERS%22
-:%0A    
+)) %7B%0A
         
@@ -1275,36 +1275,32 @@
 put(separator);%0A
-    
             clie
@@ -1348,36 +1348,32 @@
 %22);%0A            
-  
-  
 client.pushOutpu
@@ -1378,36 +1378,32 @@
 put(separator);%0A
-    
             clie
@@ -1464,31 +1464,180 @@
     
-    break;%0A            
+%7D%0A        else if(input.startsWith(%22PLAYER%22)) %7B%0A            // Check status of player%0A        %7D%0A        else if(input.startsWith(%22STATUS%22)) %7B%0A            // Get game status
 %0A   
@@ -1645,25 +1645,144 @@
     
+%7D%0A
     
-default:%0A    
+    else if(input.startsWith(%22VOTE%22)) %7B%0A            // If player can vote%0A            // Run vote action%0A        %7D%0A        else %7B%0A
     
@@ -1822,20 +1822,16 @@
         
-  
-  
 ServerMe
@@ -1860,20 +1860,16 @@
 cast = %0A
-    
         
@@ -1947,28 +1947,24 @@
             
-    
 this.serverO
@@ -1998,20 +1998,16 @@
         
- 
-   
 broadcas
@@ -2021,27 +2021,8 @@
 ();%0A
-            break;%0A
     

Fix Connector parseInput()