Esempio n. 1
0
  @Override
  public void actionPerformed(ActionEvent e) {
    // TODO Auto-generated method stub
    Sender sd = new Sender(Server.writers);
    if (click == false && game.checkWin() < 0 && game.getPalyers().size() > 0) {
      player = game.getTurn();
      if (game.getTurn() == UI.myID) {
        game.makeMove(game.getTurn(), x_pos, y_pos);
        paint();
        click = true;
        Message m = new Message(0, player, x_pos, y_pos);
        sd.sendBoardcast(m.toString());
      }

      if (game.checkWin() >= 0) {
        UI.lblGiiliran.setText(game.getPalyers().get(game.checkWin()).getName() + " menang !");
        Message m = new Message(2, game.checkWin());
        sd.sendBoardcast(m.toString());
      } else {

        UI.lblGiiliran.setText("Giliran " + game.getPalyers().get(game.getTurn()).getName());
        Message m2 = new Message(1, game.getTurn());
        sd.sendBoardcast(m2.toString());
      }
    }
  }
Esempio n. 2
0
  public static void main(String[] args) {
    ServerSocket serverSocket = null;
    Socket socket = null;

    try {
      // 서버소켓을 생성하면 7777번 포트와 결합(bind)시킨다.
      serverSocket = new ServerSocket(7777);
      System.out.println("서버가 준비되었습니다.");

      socket = serverSocket.accept();

      Sender sender = new Sender(socket);
      Receiver receiver = new Receiver(socket);

      sender.start();
      receiver.start();
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
Esempio n. 3
0
 private void parseMessage(
     String message, Socket clientSocket, BufferedReader br, BufferedWriter bw) {
   MessageClientService newMsg = new MessageClientService(message);
   odpowiedz(newMsg.getSendMessage(), clientSocket, br, bw);
   sender.giveRequest(message);
 }