Index: client/Client/main.cpp
===================================================================
--- client/Client/main.cpp	(revision 0cc431dfc1d8ca16c42c0e4b9ad99b0509626931)
+++ client/Client/main.cpp	(revision 171c4fe27d3dc99de40df4f9db5468be6790acc3)
@@ -140,6 +140,6 @@
    struct sockaddr_in server, from;
    struct hostent *hp;
-   //char buffer[256];
    NETWORK_MSG msgTo, msgFrom;
+   string username;
 
    if (argc != 3) {
@@ -162,15 +162,4 @@
    server.sin_port = htons(atoi(argv[2]));
 
-   strcpy(msgTo.buffer, "Hello");
-   n=sendMessage(&msgTo, sock, &server);
-   if (n < 0)
-      error("sendMessage");
-
-   n = receiveMessage(&msgFrom, sock, &from);
-   if (n < 0)
-      error("receiveMessage");
-	
-   chatConsole.addLine(msgFrom.buffer);
-
    al_start_timer(timer);
  
@@ -215,7 +204,16 @@
                case STATE_START:
                   msgTo.type = MSG_TYPE_LOGIN;
+                  username = input;
                   break;
                case STATE_LOGIN:
-                  msgTo.type = MSG_TYPE_CHAT;
+                  if (input.compare("quit") == 0 ||
+                      input.compare("exit") == 0 ||
+                      input.compare("logout") == 0)
+                  {
+                     strcpy(msgTo.buffer, username.c_str());
+                     msgTo.type = MSG_TYPE_LOGOUT;
+                  }
+                  else
+                     msgTo.type = MSG_TYPE_CHAT;
                   break;
                default:
@@ -234,14 +232,32 @@
                switch(state)
                {
-               case STATE_START:
-                  state = STATE_LOGIN;
-                  break;
-               case STATE_LOGIN:
-                  chatConsole.addLine(string(msgFrom.buffer));
-                  cout << "Added new line" << endl;
-                  break;
-               default:
-                  cout << "The state has an invalid value: " << state << endl;
-                  break;
+                  case STATE_START:
+                  {
+                     string loginResponse = string(msgFrom.buffer);
+                     chatConsole.addLine(string(msgFrom.buffer));
+
+                     if (loginResponse.compare("Player has already logged in.") == 0)
+                     {
+                        cout << "User login failed" << endl;
+                        username.clear();
+                     }
+                     else
+                     {
+                        cout << "User login successful" << endl;
+                        state = STATE_LOGIN;
+                     }
+                     break;
+                  }
+                  case STATE_LOGIN:
+                  {
+                     chatConsole.addLine(string(msgFrom.buffer));
+                     cout << "Added new line" << endl;
+                     break;
+                  }
+                  default:
+                  {
+                     cout << "The state has an invalid value: " << state << endl;
+                     break;
+                  }
                }
             }
