Advertisement
Guest User

Untitled

a guest
Jun 9th, 2018
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.35 KB | None | 0 0
  1. //Servidor
  2. while (protocolSI.GetCmdType() != ProtocolSICmdType.EOT)
  3. {
  4. networkStream.Read(protocolSI.Buffer, 0, protocolSI.Buffer.Length);
  5. if (protocolSI.GetCmdType() == ProtocolSICmdType.USER_OPTION_2)
  6. {
  7. string usernamestring = null;
  8. string pass = null;
  9.  
  10. usernamestring = protocolSI.GetStringFromData();
  11.  
  12. Console.WriteLine("Attempt to login from" + usernamestring);
  13.  
  14. networkStream.Read(protocolSI.Buffer, 0, protocolSI.Buffer.Length);
  15. if (protocolSI.GetCmdType() == ProtocolSICmdType.DATA)
  16. {
  17. pass = protocolSI.GetStringFromData();
  18. }
  19.  
  20. IsClientLoggeIn = logReg.VerifyLogin(usernamestring, pass);
  21. }
  22. }
  23.  
  24. //cliente
  25.  
  26. ProtocolSI protocolSI = new ProtocolSI();
  27.  
  28. string username = textBoxUsername.Text;
  29.  
  30. string password = textBoxPassword.Text;
  31.  
  32. byte[] userpacket = protocolSI.Make(ProtocolSICmdType.USER_OPTION_2, username);
  33. networkStream.Write(userpacket, 0, userpacket.Length);
  34.  
  35. byte[] passpacket = protocolSI.Make(ProtocolSICmdType.DATA, password);
  36. networkStream.Write(passpacket, 0, passpacket.Length);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement