|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.lang.Thread
energyTycoon.server.Server
public class Server
The main server class, manage all games ...
Nested Class Summary |
---|
Nested classes/interfaces inherited from class java.lang.Thread |
---|
java.lang.Thread.State, java.lang.Thread.UncaughtExceptionHandler |
Field Summary |
---|
Fields inherited from class java.lang.Thread |
---|
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY |
Constructor Summary | |
---|---|
Server(int maxGame,
int maxClient,
int port)
Server constructor |
|
Server(int maxGame,
int maxClient,
int port,
boolean clientMode)
Server constructor (client mode) |
Method Summary | |
---|---|
void |
addPowerStationType(PowerStationType pst)
|
void |
createGame(int clientId,
java.lang.String gameName,
int scriptId,
int money,
int maxPlayer)
|
void |
deleteClient(int clientId)
a client leave the server |
void |
deleteGame(int gameId)
delete the specified game from game list |
java.util.Vector<PowerStationGroup> |
getAllPowerStationGroups()
|
java.lang.String |
getAllPowerStationGroupsDefinition()
all power station for network |
PowerStationType |
getBatteryPowerStationType()
get the battery power station type |
int |
getNbClient()
get the number of clients |
int |
getNbGame()
get the number of hosted games |
PowerStationGroup |
getPowerStationGroupFromName(java.lang.String name)
get the power station group having the given name |
java.lang.String |
getScriptFileName(int scriptId)
get the script name |
boolean |
isClientMode()
|
void |
joinGame(int clientId,
int gameId)
a client try to join a game |
void |
kill()
|
void |
listGames(int clientId)
send the games list to a client |
void |
listScripts(int clientId)
send the scripts list to a client |
void |
loadPowerStations()
load power stations groups |
void |
run()
run the server (receive client loop) |
void |
sendGameStart()
Send all game initialization to all players |
void |
sendInitialization(int clientId)
Initialize connection : join game or list games |
void |
sendMessageToNoGame(java.lang.String message)
Send a message to all clients without any games |
void |
setBatteryPowerStationType(PowerStationType pst)
set battery power station type |
void |
setGameInvisible(int gameId)
Set game not visible on network ( before deleting or starting ) |
boolean |
waitStarted()
wait the server to be started |
Methods inherited from class java.lang.Thread |
---|
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yield |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public Server(int maxGame, int maxClient, int port)
maxGame
- maximum game numbermaxClient
- maximum client numberport
- server portpublic Server(int maxGame, int maxClient, int port, boolean clientMode)
maxGame
- maximum game numbermaxClient
- maximum client numberport
- server portclientMode
- is the server run in client mode (just one game)Method Detail |
---|
public int getNbGame()
public int getNbClient()
public boolean waitStarted()
public void run()
run
in interface java.lang.Runnable
run
in class java.lang.Thread
public void sendInitialization(int clientId)
clientId
- client idpublic void listGames(int clientId)
clientId
- client IDpublic void listScripts(int clientId)
clientId
- client IDpublic void sendMessageToNoGame(java.lang.String message)
message
- message to sendpublic void joinGame(int clientId, int gameId)
clientId
- client idgameId
- game idpublic void createGame(int clientId, java.lang.String gameName, int scriptId, int money, int maxPlayer)
clientId
- client id creating gamegameName
- game namescriptId
- script idmoney
- money we start withmaxPlayer
- maximum player numberpublic void deleteClient(int clientId)
clientId
- client id to removepublic void deleteGame(int gameId)
gameId
- public void setGameInvisible(int gameId)
gameId
- public void sendGameStart()
public java.lang.String getScriptFileName(int scriptId)
scriptId
- script id
public void kill()
public boolean isClientMode()
public void loadPowerStations()
public void addPowerStationType(PowerStationType pst)
addPowerStationType
in interface PowerStationListener
public PowerStationGroup getPowerStationGroupFromName(java.lang.String name)
name
-
public java.lang.String getAllPowerStationGroupsDefinition()
public PowerStationType getBatteryPowerStationType()
public void setBatteryPowerStationType(PowerStationType pst)
setBatteryPowerStationType
in interface PowerStationListener
pst
- public java.util.Vector<PowerStationGroup> getAllPowerStationGroups()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |