Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private Player getPlayer() throws Exception {
- //Infinite loop until successful connection with a socket
- while (true) {
- //Waiting for a socket to connect
- s = serverSocket.accept();
- //Setting timeout for connection reads
- s.setSoTimeout(2000);
- reader = new BufferedReader(new InputStreamReader(s.getInputStream()));
- writer = new PrintWriter(s.getOutputStream(), true);
- //Waiting 2 seconds for socket to send lobby code
- clientCode = reader.readLine();
- clientName = reader.readLine();
- //Making sure lobby code is correct
- boolean isUniqueName = true;
- if (code.equals(clientCode)) {
- writer.println(lobbySize);
- writer.println(language);
- return new Player(s);
- } else {
- writer.println("F");
- s.close();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement