Package belotetime.application.server

Source Code of belotetime.application.server.GameServer

package belotetime.application.server;

import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;

import com.sun.swing.internal.plaf.synth.resources.synth;

import belotetime.application.game.Game;

public class GameServer
{
  private ArrayList<GameClient> clients;
  private boolean gameStarted;
  private Game game;
  public static int cnt;
 
  public GameServer()
  {
    clients = new ArrayList<>();
    gameStarted = false;
    game = new Game();
    cnt = 0;
  }
 
  public synchronized void addPlayer(GameClient client)
  {
    clients.add(client);
  }

  public synchronized ArrayList<GameClient> getClients()
  {
    return clients;
  }

  public void setClients(ArrayList<GameClient> clients)
  {
    this.clients = clients;
  }
 
  public synchronized void sendAll(String response) throws IOException
  {
    for(GameClient c : clients)
    {
      c.getResponse().writeUTF(response);
    }
  }

  public synchronized boolean isGameStarted()
  {
    return gameStarted;
  }
 
  public synchronized void setGameStarted(boolean gameStarted)
  {
    this.gameStarted = gameStarted;
  }

  public Game getGame()
  {
    return game;
  }

  public void setGame(Game game)
  {
    this.game = game;
  }
}
TOP

Related Classes of belotetime.application.server.GameServer

TOP
Copyright © 2018 www.massapi.com. 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.