Example #1
0
 public void Login(string username, string password)
 {
     Console.WriteLine("login packet, username: "******", wachtwoord: " + password);
     //Test sending back:
     NetworkCommunication.SendPacket(new PacketLogin(true), stream);
     //Moet je maar ff in project pakke en kopiere en aanpasse op structuur;
 }
 /// <summary>
 /// Check if username and password are correct and send a response.</summary>
 /// <param name="username">The username of the user</param>
 /// <param name="password">The password of the user</param>
 public void Login(string username, string password)
 {
     Console.WriteLine("Iemand probeert in te loggen als " + username + ", wachtwoord: " + password);
     //Actual login checking:
     foreach (User user in server.users)
     {
         if (user.username.ToLower().Equals(username.ToLower()))
         {
             if (PasswordHash.ValidatePassword(password, user.password))
             {
                 NetworkCommunication.SendPacket(new PacketLoginResponse(true, user.accessRights), stream);
                 Console.WriteLine("{0} succesfully logged in.", username);
                 this.user = user;
                 break;
             }
             else //wrong password
             {
                 Console.WriteLine("wrong password");
                 NetworkCommunication.SendPacket(new PacketLoginResponse(false, user.accessRights), stream);
                 break;
             }
         }
     }
 }
 /// <summary>
 /// Send a packet to the server.</summary>
 /// <param name="packet">The packet that will be send</param>
 public void sendPacket(Packet packet)
 {
     NetworkCommunication.SendPacket(packet, ssl);
 }
 public void GetWerkbonnen()
 {
     Console.WriteLine("Someone is requesting all werkbonnen " + server.werkbonnen.Count);
     NetworkCommunication.SendPacket(new PacketGetWerkbonnenResponse(server.werkbonnen), stream);
 }
 public void GetUsers()
 {
     Console.WriteLine("Someone is requesting all users");
     NetworkCommunication.SendPacket(new PacketGetUsersResponse(server.users), stream);
 }