Package core

Examples of core.PC


    try {
      r.next();

      String ip = r.getString("ip");
      int status = r.getInt("lastonline");
      PC pc = new PC(id, ip, status);
      return pc;
    } catch (SQLException e) {
      throw new IllegalArgumentException("I found no pc with index " + id);
    }
View Full Code Here


    while (r.next()) {
      String ip = r.getString("ip");
      int status = r.getInt("lastonline");
      String id = r.getString("id");

      PC pc = new PC(id, ip, status);
      result.add(pc);
    }

    return result.toArray(new PC[]{});
  }
View Full Code Here

    this.sema.acquire();
    this.checkContent(TransmissionConstants.CONTENT_PC);
   
    int st = this.is.readInt();
   
    PC p;
    if(st == TransmissionConstants.STATUS_PC_AVAILABLE) {
      String id = this.is.readUTF();
      String ip = this.is.readUTF();
      int status = this.is.readInt();
     
      p = new PC(id, ip, status);
    } else if (st == TransmissionConstants.STATUS_PC_NOT_AVAILABLE) {
      p = null;
    } else {
      this.sema.release();
      throw new ProtocolException("Unexpected data received");
View Full Code Here

   
    if(pcs.length == 0)
      this.wos.writePC(null);
   
    Random r = new Random();
    PC p = pcs[r.nextInt(pcs.length)];
   
    Output.p("Sending PC with ID " + p.getID() + " and IP " + p.getIP() + " to client " + this.sock.getInetAddress() + ":" + this.sock.getLocalPort());
    this.wos.writePC(p);
    Output.p("PC sent");
  }
View Full Code Here

public class Transport {
 
  public static void upload(File f) throws UnknownHostException, IOException, HandshakeException, InterruptedException, ClassNotFoundException {
    Output.p("Querying PC");
   
    PC p = Wrapper.getOnlinePc();
    if(p==null) {
      Output.p("No PCs available!");
    } else {
      Output.p("Uploading file to " + p);

      TransportSocket ts = new TransportSocket(p.getIP());
      ts.uploadFile(f);     
    }
  }
View Full Code Here

    Output.p("Sending request");
    os.writeCommand(TransmissionConstants.COMMAND_GET_ONLINE_PC);

    // Retrieving response
    Output.p("Retrieving response");
    PC p = is.readPC();
   
    Output.p("PC fetched");
   
    Wrapper.sema.release();
   
View Full Code Here

TOP

Related Classes of core.PC

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.