Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void logout_request(Packet inPacket, Socket socket) {
- // For each user that attempts to log in, the server verifies the validity
- // of the login request.
- // If the server is not at maximum capacity, it allows the log in to
- // proceed.
- // If the server is at capacity, the user connection is placed on a waiting
- // queue of limited size.
- // Process the logout
- // Lookup the user and get username
- ClientHandlerThread handler = clientHandlerThreads.get(socket);
- User usr = handler.getUser();
- String username = usr.getUsername();
- //call logoff
- User waiting_user = logoff(username);
- //reset the user logged into the client handler
- handler.resetUser();
- //Create a packet and send it to this waiting_user that was accepted off the wait queue
- // Create packet filled in with status
- Packet packet = new Packet(Type.LOGOUT, Status.OK, "");
- // Send packet
- sendPacket(packet, socket);
- }
Add Comment
Please, Sign In to add comment