示例#1
0
文件: Paket.java 项目: toka88/sedmica
  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;
  }
示例#2
0
文件: Paket.java 项目: toka88/sedmica
  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;
  }