Arreglado distintos clientes
This commit is contained in:
		
							parent
							
								
									b0db99d83a
								
							
						
					
					
						commit
						5e4545cbfb
					
				| @ -29,24 +29,28 @@ public class ComunacacionJugador extends Thread{ | |||||||
| 			 | 			 | ||||||
| 			if(Servidor.salas.get(sala).getJugador1().equals(this.socket)) { | 			if(Servidor.salas.get(sala).getJugador1().equals(this.socket)) { | ||||||
| 				bufferSalida.println("Esperando al segundo jugador"); | 				bufferSalida.println("Esperando al segundo jugador"); | ||||||
| 				synchronized (getClass()) { | 				synchronized (this.socket) { | ||||||
| 					this.getClass().wait(); | 					this.socket.wait(); | ||||||
| 				} | 				} | ||||||
| 				turno = 1; | 				turno = 1; | ||||||
| 				bufferSalida.println("Primero"); | 				bufferSalida.println("Primero"); | ||||||
| 				bufferSalida.println(Servidor.salas.get(sala).tablero.getTablero()); | 				bufferSalida.println(Servidor.salas.get(sala).tablero.getTablero()); | ||||||
| 				Servidor.salas.get(sala).tablero.colocarFicha(Integer.parseInt(bufferEntrada.readLine()),  | 				Servidor.salas.get(sala).tablero.colocarFicha(Integer.parseInt(bufferEntrada.readLine()),  | ||||||
| 						Integer.parseInt(bufferEntrada.readLine()),turno); | 						Integer.parseInt(bufferEntrada.readLine()),turno); | ||||||
| 				synchronized (getClass()) { | 				synchronized (Servidor.salas.get(sala).jugadores[turno%2]) { | ||||||
| 					this.getClass().notifyAll(); | 					Servidor.salas.get(sala).jugadores[turno%2].notify(); | ||||||
| 					this.getClass().wait(); | 				} | ||||||
|  | 				synchronized (this.socket) { | ||||||
|  | 					this.socket.wait(); | ||||||
| 				} | 				} | ||||||
| 			}else { | 			}else { | ||||||
| 				bufferSalida.println("Iniciando partida"); | 				bufferSalida.println("Iniciando partida"); | ||||||
| 				bufferSalida.println("Segundo"); | 				bufferSalida.println("Segundo"); | ||||||
| 				synchronized (getClass()) { | 				synchronized (Servidor.salas.get(sala).jugadores[turno%2]) { | ||||||
| 					this.getClass().notifyAll(); | 					Servidor.salas.get(sala).jugadores[turno%2].notify(); | ||||||
| 					this.getClass().wait(); | 				} | ||||||
|  | 				synchronized (this.socket) { | ||||||
|  | 					this.socket.wait(); | ||||||
| 				} | 				} | ||||||
| 			} | 			} | ||||||
| 			while(continuar) { | 			while(continuar) { | ||||||
| @ -58,16 +62,18 @@ public class ComunacacionJugador extends Thread{ | |||||||
| 					}else { | 					}else { | ||||||
| 						bufferSalida.println("f"); | 						bufferSalida.println("f"); | ||||||
| 					} | 					} | ||||||
| 					synchronized (getClass()) { | 					synchronized (Servidor.salas.get(sala).jugadores[turno%2]) { | ||||||
| 						this.getClass().notifyAll(); | 						Servidor.salas.get(sala).jugadores[turno%2].notify(); | ||||||
| 					} | 					} | ||||||
| 				}else { | 				}else { | ||||||
| 					bufferSalida.println(Servidor.salas.get(sala).tablero.getTablero()); | 					bufferSalida.println(Servidor.salas.get(sala).tablero.getTablero()); | ||||||
| 					Servidor.salas.get(sala).tablero.colocarFicha(Integer.parseInt(bufferEntrada.readLine()),  | 					Servidor.salas.get(sala).tablero.colocarFicha(Integer.parseInt(bufferEntrada.readLine()),  | ||||||
| 							Integer.parseInt(bufferEntrada.readLine()),turno); | 							Integer.parseInt(bufferEntrada.readLine()),turno); | ||||||
| 					synchronized (getClass()) { | 					synchronized (Servidor.salas.get(sala).jugadores[turno%2]) { | ||||||
| 						this.getClass().notifyAll(); | 						Servidor.salas.get(sala).jugadores[turno%2].notify(); | ||||||
| 						this.getClass().wait(); | 					} | ||||||
|  | 					synchronized (this.socket) { | ||||||
|  | 						this.socket.wait(); | ||||||
| 					} | 					} | ||||||
| 				} | 				} | ||||||
| 				 | 				 | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user