示例#1
0
  @Override
  public void run() {
    getAndSendInitialInfo();
    System.out.println("CLIENT " + userid + ": registered on team " + team);

    while (true) {
      int plen = ClientState.getMaxSize();
      byte[] buf = cs.toBytes();
      DatagramPacket cp = new DatagramPacket(buf, plen);
      try {
        ds.send(cp);
        Thread.sleep(50);
      } catch (IOException | InterruptedException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
      }
    }
    // send client state
    // receive client data
  }
示例#2
0
  public MockClient(String host, int port, int userid) {
    this.userid = userid;
    try {
      ds = new DatagramSocket();
      ds.connect(InetAddress.getByName(host), port);
    } catch (SocketException | UnknownHostException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }

    cs = new ClientState(userid);
    cs.yVote = 50;
  }