private void OnIncomingData(ServerClient c, string data) { // Debug.Log(data); if (data.Length >= 5 && data.Substring(0, 5).Equals("&NAME")) { string[] info = data.Split('|'); string user = info[1]; string pass = info[2]; if (nameToClient.ContainsKey(user)) { // Broadcast("The name " + user + " has already been taken", new List<ServerClient>() { c }); // Debug.Log("Attempted password: "******", Real password: "******"Logged in as " + user); Broadcast("099", nameToClient[user].clientName, new List <ServerClient>() { c }); Connect(c, user); } else { Debug.Log("Wrong password: "******"299", "", new List <ServerClient>() { c }); FailedConenct(c); } // Broadcast("The name " + user + " has already been taken", new List<ServerClient>() { c }); } else { Debug.Log("Wrong Username: "******"199", "", new List <ServerClient>() { c }); FailedConenct(c); } return; } if (data.Length >= 6 && data.Substring(0, 6).Equals("&&NAME")) { string[] info = data.Split('|'); string user = info[1]; string pass = info[2]; if (nameToClient.ContainsKey(user)) { Debug.Log("Username Taken: " + user); Broadcast("399", "", new List <ServerClient>() { c }); FailedConenct(c); } else { Debug.Log("Registered as: " + user); Broadcast("099", user, new List <ServerClient>() { c }); Register(c, user, pass); Save(); } return; } int selection = Int32.Parse(data.Substring(0, 3)); switch (selection) { case 3: CheckPlayerOnline(data.Substring(3), c); break; case 4: string selection2 = data.Substring(3, 1); // Debug.Log(selection2); switch (selection2) { case "P": ExtractPassword(data.Substring(4), c); break; case "L": ExtractLogs(data.Substring(4), c); break; case "T": TestPassword(data.Substring(4), c); break; default: Debug.Log("I messed up trying to extract something!"); break; } break; case 5: int creditChange = Int32.Parse(data.Substring(3)); c.ChangeCredits(creditChange); Save(); UpdateCredits(c.GetCredits(), c); break; case 6: UpdateMap(c); break; case 16: UpdateMapPiece(data.Substring(3), c); break; default: Broadcast("That command does NOTHING", new List <ServerClient>() { c }); break; } /* if (nameToClient.ContainsKey(data)) //// THIS IS WHERE THE DATA IS (delete it all) * Attack(c, data); * else * Broadcast(c.clientName+" : attacked the air!", clients); */ }