Index: server/server.cpp
===================================================================
--- server/server.cpp	(revision 0cc431dfc1d8ca16c42c0e4b9ad99b0509626931)
+++ server/server.cpp	(revision d2b411afb1f24e8dc56eee5b72ceefd6d51e5344)
@@ -21,5 +21,22 @@
 #include "player.h"
 #include "../common/message.h"
-///////////
+
+/*
+ Protocol Design
+
+ Client sends a login message
+ Server replies with client's position in the world and positions of
+ oall other logged in players
+ Merver sends player ids along with locations
+ This means a newly logged in client will need to know which id is
+ assigned to it
+ So server needs to send an id message, wait for an ack, and then send
+ the location messages
+ When a client shuts down, it sends a message to indicate this so the
+ server can remove it from the list of connected clients
+ Eventually, there'll need to be a way to detect timeouts from clients
+ (if they crashed or otherwise failed to send the logout message)
+*/
+
 using namespace std;
 
@@ -81,29 +98,18 @@
       if (n < 0)
          error("recieveMessage");
-      cout << "msg: " << clientMsg.buffer << endl;
-
-      // Ptoyovol Design
-      //
-      // Client sends a login message
-      // Server replies with client's position in the world and positions of
-      // oall other logged in players
-      // Merver sends player ids along with locations
-      // This means a newly logged in client will need to know which id is
-      // assigned to it
-      // So server needs to send an id message, wait for an ack, and then send
-      // the location messages
-
-      // When a client shuts down, it sends a message to indicate this so the
-      // server can remove it from the list of connected clients
-      // Eventually, there'll need to be a way to detect timeouts from clients
-      // (if they crashed or otherwise failed to send the logout message)
-
-      if (strcmp(clientMsg.buffer, "Hello") == 0)
-      {
-         player *p = findPlayerByName(vctPlayers, "Boberty");
+      cout << "MSG: type: " << clientMsg.type << " contents: " << clientMsg.buffer << endl;
+
+      switch(clientMsg.type)
+      {
+      {
+      case MSG_TYPE_LOGIN:
+         string name(clientMsg.buffer);
+         cout << "Player logging in: " << name << endl;
+
+         player *p = findPlayerByName(vctPlayers, name);
 
          if (p == NULL)
          {
-            vctPlayers.push_back(player("Boberty", from));
+            vctPlayers.push_back(player(name, from));
             strcpy(serverMsg.buffer, "I'm thinking of a number between 1 and 1000. Guess what it is.");
          }
@@ -112,5 +118,11 @@
             strcpy(serverMsg.buffer, "Player has already logged in.");
          }
-      }else {
+
+         serverMsg.type = MSG_TYPE_LOGIN;
+
+         break;
+      }
+      case MSG_TYPE_CHAT:
+      {
          int guess = atoi(clientMsg.buffer);
 
@@ -127,5 +139,50 @@
             num = (rand() % 1000) + 1;
          }	
-      }
+
+         serverMsg.type = MSG_TYPE_CHAT;
+
+         break;
+      }
+      default:
+      {
+         strcpy(serverMsg.buffer, "Server error occured. Report this please.");
+
+         serverMsg.type = MSG_TYPE_CHAT;
+
+         break;
+      }
+      }
+
+      /*
+      if (strcmp(clientMsg.buffer, "Hello") == 0)
+      {
+         player *p = findPlayerByName(vctPlayers, "Boberty");
+
+         if (p == NULL)
+         {
+            vctPlayers.push_back(player("Boberty", from));
+            strcpy(serverMsg.buffer, "I'm thinking of a number between 1 and 1000. Guess what it is.");
+         }
+         else
+         {
+            strcpy(serverMsg.buffer, "Player has already logged in.");
+         }
+      }else {
+         int guess = atoi(clientMsg.buffer);
+
+         cout << "guess: " << guess << endl;
+
+         if (guess < 1 || guess > 1000) {
+            strcpy(serverMsg.buffer, "You must guess a number between 1 and 1000");
+         }else if(guess > num)
+            strcpy(serverMsg.buffer, "The number I'm thinking of is less than that.");
+         else if(guess < num)
+            strcpy(serverMsg.buffer, "The number I'm thinking of is greater than that.");
+         else if(guess == num) {
+            strcpy(serverMsg.buffer, "Congratulations! I will now think of a new number.");
+            num = (rand() % 1000) + 1;
+         }	
+      }
+      */
 
       cout << "msg: " << serverMsg.buffer << endl;
