Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void comunicate()
- {
- lerFicheiro();
- int count = 0; // para contar o numero de votos recebidos!!!!
- byte[] user = new byte[1024];
- int k = socket.Receive(user);
- response = Encoding.ASCII.GetString(user, 0, k);
- Console.WriteLine("Numero do eleitor: ->" + response); // NAO Γ PRECISO MOSTRAR PORQUE Γ UMA VOTAΓAO ANONIMA!!!
- byte[] data = new byte[1024];
- int j = socket.Receive(data);
- Console.Write("-> ");
- s = Encoding.ASCII.GetString(data, 0, j); // AQUI RECEBE O VOTO DO UTILIZADOR
- Console.WriteLine(s);
- canVote(s);
- }
- public string canVote(string s)
- {
- string aux = "";
- string[] lines = System.IO.File.ReadAllLines(@"C:\Users\DC\Documents\HighSchool\arc\eleitores.txt");
- foreach (string line in lines)
- {
- if (s == line.Split(';')[0])
- {
- if (line.Split(';')[2] == "0")
- {
- aux = "0";
- byte[] user = Encoding.ASCII.GetBytes(s); // transforma a msg em codigo e envia-o
- socket.Send(user);
- }
- else if (line.Split(';')[2] == "1")
- {
- aux = "1";
- byte[] user2 = Encoding.ASCII.GetBytes("Nao PODE VOTAR"); // transforma a msg em codigo e envia-o
- socket.Send(user2);
- }
- }
- }
- return aux;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement