public LjudiUSobi dohvatiLjudeUSobi(int idSobe, int kljucKorisnika) { connect(); try { ObjectOutputStream paketZaServer = new ObjectOutputStream(klijentSocket.getOutputStream()); NabaviPaket paket = new NabaviPaket(16); paket.setIdSobe(idSobe); paket.setKljuc(kljucKorisnika); paketZaServer.writeObject(paket); ObjectInputStream paketOdServera = new ObjectInputStream(klijentSocket.getInputStream()); NabaviPaket paketLjudima = (NabaviPaket) paketOdServera.readObject(); paketZaServer.close(); paketOdServera.close(); LjudiUSobi ljudi = new LjudiUSobi(); ljudi.setLjudiUSobi(paketLjudima.getUser().split(",")); ljudi.setMaxLjudi(paketLjudima.getKljuc()); return ljudi; } catch (IOException ioe) { System.out.println("Iznimka ulaza/izlaza"); System.exit(1); } catch (ClassNotFoundException k) { System.out.println("Dobivena kriva klasa " + k); } finally { close(); } return null; }
public String cekajIgrace(int idSobe) { connect(); try { ObjectOutputStream paketZaServer = new ObjectOutputStream(klijentSocket.getOutputStream()); NabaviPaket paket = new NabaviPaket(28); paket.setIdSobe(idSobe); paketZaServer.writeObject(paket); ObjectInputStream paketOdServera = new ObjectInputStream(klijentSocket.getInputStream()); NabaviPaket paketSKljucem = (NabaviPaket) paketOdServera.readObject(); paketZaServer.close(); paketOdServera.close(); return paketSKljucem.getUser(); } catch (IOException ioe) { System.out.println("Iznimka ulaza/izlaza"); System.exit(1); } catch (ClassNotFoundException k) { System.out.println("Dobivena kriva klasa " + k); } finally { close(); } return null; }