Guest User

Untitled

a guest
Jan 23rd, 2018
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.94 KB | None | 0 0
  1. public void logout_request(Packet inPacket, Socket socket) {
  2. // For each user that attempts to log in, the server verifies the validity
  3. // of the login request.
  4. // If the server is not at maximum capacity, it allows the log in to
  5. // proceed.
  6. // If the server is at capacity, the user connection is placed on a waiting
  7. // queue of limited size.
  8.  
  9. // Process the logout
  10. // Lookup the user and get username
  11. ClientHandlerThread handler = clientHandlerThreads.get(socket);
  12. User usr = handler.getUser();
  13. String username = usr.getUsername();
  14.  
  15. //call logoff
  16. User waiting_user = logoff(username);
  17.  
  18. //reset the user logged into the client handler
  19. handler.resetUser();
  20.  
  21. //Create a packet and send it to this waiting_user that was accepted off the wait queue
  22.  
  23.  
  24. // Create packet filled in with status
  25. Packet packet = new Packet(Type.LOGOUT, Status.OK, "");
  26.  
  27. // Send packet
  28. sendPacket(packet, socket);
  29. }
Add Comment
Please, Sign In to add comment