|
JSettlers v1.0.6 API Built ${date} |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.lang.Thread
soc.server.genericServer.Server
soc.server.SOCServer
A server for Settlers of Catan
Field Summary | |
protected SOCChannelList |
channelList
list of chat channels |
protected java.util.Hashtable |
gameDataFiles
table of game data files |
protected SOCGameList |
gameList
list of soc games |
protected int |
maxConnections
Maximum number of connections allowed |
protected int |
numberOfGamesFinished
the total number of games finished |
protected int |
numberOfGamesStarted
the total number of games that have been started |
protected int |
numberOfUsers
total number of users |
int |
port
The TCP port we listen on. |
protected java.util.Hashtable |
robotDismissRequests
table of requestst for robots to leave games |
protected java.util.Hashtable |
robotJoinRequests
table of requests for robots to join games |
protected java.util.Vector |
robots
A list of robots connected to this server |
static java.lang.String |
SERVERNAME
Name used when sending messages from the server. |
protected long |
startTime
the time that this server was started |
Fields inherited from class soc.server.genericServer.Server |
conns, error, inQueue, numberOfConnections |
Fields inherited from class java.lang.Thread |
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY |
Constructor Summary | |
SOCServer(int p,
int mc,
java.lang.String databaseUserName,
java.lang.String databasePassword)
Create a Settlers of Catan server listening on port p. |
Method Summary | |
protected void |
broadcastGameStats(SOCGame ga)
this broadcasts game information to all people connected used to display the scores on the player client |
void |
checkForExpiredGames()
check for games that have expired and destroy them if games are about to expire, send a warning |
protected boolean |
checkTurn(Connection c,
SOCGame ga)
make sure it's the player's turn |
void |
connectToChannel(Connection c,
java.lang.String ch)
Adds a connection to a chat channel. |
boolean |
connectToGame(Connection c,
java.lang.String ga)
Adds a connection to a game. |
void |
destroyGame(java.lang.String gm)
destroy the game WARNING: MUST HAVE THE gameList.takeMonitor() before calling this method |
protected void |
giveDevCard(java.lang.String mes,
SOCGame game)
this is a debugging command that gives a dev card to a player |
protected void |
giveResources(java.lang.String mes,
SOCGame game)
this is a debugging command that gives resources to a player |
java.util.Vector |
leaveAllChannels(Connection c)
the connection c leaves all channels it was in |
java.util.Vector |
leaveAllGames(Connection c)
the connection c leaves all games it was in |
boolean |
leaveChannel(Connection c,
java.lang.String ch,
boolean channelListLock)
the connection c leaves the channel ch WARNING: MUST HAVE THE channelList.takeMonitorForChannel(ch) before calling this method |
void |
leaveConnection(Connection c)
things to do when the connection c leaves |
boolean |
leaveGame(Connection c,
java.lang.String gm,
boolean gameListLock)
the connection c leaves the game gm WARNING: MUST HAVE THE gameList.takeMonitorForGame(gm) before calling this method |
static void |
main(java.lang.String[] args)
Starting the server from the command line |
void |
messageToChannel(java.lang.String ch,
SOCMessage mes)
Send a message to the given channel |
void |
messageToChannelWithMon(java.lang.String ch,
SOCMessage mes)
Send a message to the given channel WARNING: MUST HAVE THE gameList.takeMonitorForChannel(ch) before calling this method |
void |
messageToGame(java.lang.String ga,
SOCMessage mes)
Send a message to the given game |
void |
messageToGameExcept(java.lang.String gn,
java.util.Vector ex,
SOCMessage mes)
Send a message to all the connections in a game excluding some. |
void |
messageToGameWithMon(java.lang.String ga,
SOCMessage mes)
Send a message to the given game WARNING: MUST HAVE THE gameList.takeMonitorForGame(ga) before calling this method |
void |
messageToPlayer(Connection c,
SOCMessage mes)
Send a message to a player and record it |
void |
newConnection(Connection c)
Things to do when a new connection comes |
void |
processCommand(java.lang.String s,
Connection c)
Treat the incomming messages Note: When there is a choice, always use local information over information from the message. |
protected void |
recordGameEvent(java.lang.String gameName,
java.lang.String event)
record events that happen during the game |
protected void |
reportBankTrade(SOCGame ga,
SOCResourceSet give,
SOCResourceSet get)
report that the current player traded with the bank |
protected void |
reportRobbery(SOCGame ga,
SOCPlayer pe,
SOCPlayer vi,
int rsrc)
The current player is stealing from another player. |
protected void |
reportTrade(SOCGame ga,
int offering,
int accepting)
report a trade that has taken place |
protected void |
sendGameState(SOCGame ga)
send the current state of the game with a message |
protected void |
startGame(SOCGame ga)
do the stuff you need to do to start a game |
protected void |
storeGameScores(SOCGame ga)
if all the players stayed for the whole game, record the scores in the database |
Methods inherited from class soc.server.genericServer.Server |
addConnection, broadcast, connectionCount, getConnections, isUp, removeConnection, removeConnectionCleanup, run, serverDown, stopServer, treat |
Methods inherited from class java.lang.Thread |
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getContextClassLoader, getName, getPriority, getThreadGroup, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setName, setPriority, sleep, sleep, start, stop, stop, suspend, toString, yield |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
public static final java.lang.String SERVERNAME
public int port
protected int maxConnections
protected java.util.Vector robots
protected SOCChannelList channelList
protected SOCGameList gameList
protected java.util.Hashtable robotJoinRequests
protected java.util.Hashtable robotDismissRequests
protected java.util.Hashtable gameDataFiles
protected long startTime
protected int numberOfGamesStarted
protected int numberOfGamesFinished
protected int numberOfUsers
Constructor Detail |
public SOCServer(int p, int mc, java.lang.String databaseUserName, java.lang.String databasePassword)
p
- the port that the server listens onmc
- the maximum number of connections alloweddatabaseUserName
- the user name for accessing the databasedatabasePassword
- the password for the userMethod Detail |
public void connectToChannel(Connection c, java.lang.String ch)
c
- the Connection to be addedch
- the name of the channelpublic boolean leaveChannel(Connection c, java.lang.String ch, boolean channelListLock)
c
- the connectionch
- the channelchannelListLock
- true if we have the channelList monitor
public boolean connectToGame(Connection c, java.lang.String ga)
c
- the Connection to be addedga
- the name of the game
public boolean leaveGame(Connection c, java.lang.String gm, boolean gameListLock)
c
- the connectiongm
- the gamegameListLock
- true if we have the gameList.takeMonitor() lock
public void destroyGame(java.lang.String gm)
gm
- the name of the gamepublic java.util.Vector leaveAllChannels(Connection c)
c
- the connection
public java.util.Vector leaveAllGames(Connection c)
c
- the connection
public void messageToChannel(java.lang.String ch, SOCMessage mes)
ch
- the name of the channelmes
- the message to sendpublic void messageToChannelWithMon(java.lang.String ch, SOCMessage mes)
ch
- the name of the channelmes
- the message to sendpublic void messageToPlayer(Connection c, SOCMessage mes)
c
- the player connectionmes
- the message to sendpublic void messageToGame(java.lang.String ga, SOCMessage mes)
ga
- the name of the gamemes
- the message to sendpublic void messageToGameWithMon(java.lang.String ga, SOCMessage mes)
ga
- the name of the gamemes
- the message to sendpublic void messageToGameExcept(java.lang.String gn, java.util.Vector ex, SOCMessage mes)
gn
- the name of the gameex
- the list of exceptionsmes
- the messagepublic void leaveConnection(Connection c)
leaveConnection
in class Server
c
- the connectionpublic void newConnection(Connection c)
newConnection
in class Server
c
- the new Connectionpublic void processCommand(java.lang.String s, Connection c)
processCommand
in class Server
s
- String containing the messagec
- the Connection that sent the Messageprotected void reportRobbery(SOCGame ga, SOCPlayer pe, SOCPlayer vi, int rsrc)
ga
- the gamepe
- the perpetratorvi
- the the victimrsrc
- what was stolenprotected void sendGameState(SOCGame ga)
ga
- the gameprotected void reportTrade(SOCGame ga, int offering, int accepting)
ga
- the gameoffering
- the number of the player making the offeraccepting
- the number of the player accepting the offerprotected void reportBankTrade(SOCGame ga, SOCResourceSet give, SOCResourceSet get)
ga
- the gamegive
- the number of the player making the offerget
- the number of the player accepting the offerprotected boolean checkTurn(Connection c, SOCGame ga)
c
- the connectionga
- the game
protected void startGame(SOCGame ga)
ga
- the gameprotected void storeGameScores(SOCGame ga)
ga
- the gameprotected void recordGameEvent(java.lang.String gameName, java.lang.String event)
gameName
- the name of the gameevent
- the eventprotected void giveResources(java.lang.String mes, SOCGame game)
protected void broadcastGameStats(SOCGame ga)
public void checkForExpiredGames()
protected void giveDevCard(java.lang.String mes, SOCGame game)
public static void main(java.lang.String[] args)
args
- arguments: port number
|
JSettlers v1.0.6 API Built ${date} |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |