|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.lang.Thread
edu.umk.mat.merdacz.JGServer.ServerThread
Main per connection while-loop
Field Summary | |
private Room |
actualRoom
The user can be only in one room at most and this is this room. |
private ServerCfg |
cfg
Reference to ServerCfg object which is needed due to checking if Debug flag is set. |
private DbWrapper |
db
db stuff |
private boolean |
depsInRoom
Indcates wheter player is in a room |
private boolean |
depsLoggedIn
Indicates whether player has already logged in. |
private boolean |
depsSetGame
Indicates whether setgame request has been made We needs this because some requests depends on the fact that a game has been chosen |
private Game |
game
Shortcut to games.getGameByName(...) |
private Games |
games
Shortcut to server.getGames(); |
private boolean |
gameUnsetted
|
private boolean |
leftRoom
Indicates whether we has just left the actualRoom We need this because of how message parsing is done. |
private Player |
player
Player object is instantinated when login or register request occurs and is succesfully done |
private boolean |
removedRoom
Indicates whether the room has been removed We need this because of how message parsing is done. |
private Rooms |
rooms
Shortcut to game.getRooms() |
private Server |
server
Reference to the Server object from which this instance of ServerThread had been created. |
private java.net.Socket |
socket
The socket for this concrete connection. |
Fields inherited from class java.lang.Thread |
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY |
Constructor Summary | |
ServerThread(Server server,
java.net.Socket socket)
|
Method Summary | |
private java.lang.String |
broadcastChatMsg(java.lang.String from,
java.lang.String msg)
Special type of broadcastInRoom for chat purposes only |
private java.lang.String |
broadcastInGame(java.lang.String type,
java.lang.String name)
Send message to all but not "name" player in whole game |
private java.lang.String |
broadcastInRoom(java.lang.String type,
java.lang.String content)
Sends messgae to all but not "name" player in actual room |
private java.lang.String |
getPlayersInGame(java.lang.String id)
|
private java.lang.String |
getPlayersInRoom(java.lang.String id,
org.jdom.Element name)
|
private java.lang.String |
getRooms(java.lang.String id)
|
private java.lang.String |
getStats(java.lang.String id)
Get statistic - simple XPath query on NXD Not implemented yet Should allow to pass XPath/XQuery queries?? |
private java.lang.String |
grantInvitation(java.lang.String id,
org.jdom.Element playerName,
org.jdom.Element roomName)
|
private java.lang.String |
joinRoom(java.lang.String id,
org.jdom.Element name)
|
private java.lang.String |
leaveRoom(java.lang.String id)
Leaves actual room. |
private java.lang.String |
login(java.lang.String id,
org.jdom.Element name,
org.jdom.Element password)
|
private java.lang.String |
logout(java.lang.String id)
Logout doesn't mean destroying connection. |
private java.lang.String |
newRoom(java.lang.String id,
org.jdom.Element name,
org.jdom.Element type)
|
private void |
parseActions(java.lang.String xmlToSend)
Parse xml's produced by parseRequest and take proper actions |
private java.lang.String |
parseRequest(java.lang.String xmlin)
|
private java.lang.String |
register(java.lang.String id,
org.jdom.Element name,
org.jdom.Element password,
org.jdom.Element passwordAgain,
org.jdom.Element avatar)
|
private java.lang.String |
removeRoom(java.lang.String id,
org.jdom.Element name)
|
private java.lang.String |
reply(java.lang.String id,
java.lang.String type,
java.lang.String content)
Generates reply with given content |
private java.lang.String |
replyFailed(java.lang.String id,
java.lang.String type,
java.lang.String reason)
Generates Failed reply for given request type, with given explaination |
private java.lang.String |
replyOK(java.lang.String id,
java.lang.String type)
Generates OK reply for given request type |
void |
run()
Main ServerThread while-loop |
private java.lang.String |
sendInvitation(java.lang.String roomName,
java.lang.String to)
|
private java.lang.String |
setGame(java.lang.String id,
org.jdom.Element name)
|
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 |
private Server server
private java.net.Socket socket
private Games games
private Game game
private Rooms rooms
private Room actualRoom
private Player player
private ServerCfg cfg
private boolean depsSetGame
private boolean depsLoggedIn
private boolean depsInRoom
private boolean removedRoom
private boolean leftRoom
private boolean gameUnsetted
private DbWrapper db
Constructor Detail |
public ServerThread(Server server, java.net.Socket socket)
server
- Reference to main server thread from which this one has been
created.socket
- Socket which is used for communication with the player.Method Detail |
public void run()
private java.lang.String parseRequest(java.lang.String xmlin) throws org.jdom.JDOMException, java.io.IOException, DbWrapperException
xmlin
- XML message from player
org.jdom.JDOMException
java.io.IOException
DbWrapperException
private void parseActions(java.lang.String xmlToSend) throws org.jdom.JDOMException, java.io.IOException
xmlToSend
-
java.io.IOException
org.jdom.JDOMException
private java.lang.String setGame(java.lang.String id, org.jdom.Element name) throws DbWrapperException
id
- Idicates for which request reply will be producedname
- node which contains name of gamelet to load
DbWrapperException
private java.lang.String login(java.lang.String id, org.jdom.Element name, org.jdom.Element password) throws DbWrapperException
id
- Idicates for which request reply will be producedname
- node which contains login name passed in requestpassword
- node which contains passoword passed in request
DbWrapperException
private java.lang.String logout(java.lang.String id)
id
- Idicates for which request reply will be produced
private java.lang.String register(java.lang.String id, org.jdom.Element name, org.jdom.Element password, org.jdom.Element passwordAgain, org.jdom.Element avatar) throws DbWrapperException
id
- Idicates for which request reply will be producedname
- node which contains login name passed in requestpassword
- node which contains password passed in requestpasswordAgain
- node which contains passwordAgain in requestavatar
- node which contains avatar which is uuencoded image
DbWrapperException
private java.lang.String getRooms(java.lang.String id)
id
- Idicates for which request reply will be produced
private java.lang.String joinRoom(java.lang.String id, org.jdom.Element name)
id
- Idicates for which request reply will be producedname
- node element which contains room name passed in request
private java.lang.String leaveRoom(java.lang.String id)
id
- Idicates for which request reply will be produced
private java.lang.String grantInvitation(java.lang.String id, org.jdom.Element playerName, org.jdom.Element roomName) throws DbWrapperException
playerName
- roomName
-
DbWrapperException
private java.lang.String getPlayersInRoom(java.lang.String id, org.jdom.Element name)
id
- Idicates for which request reply will be producedname
- Node which contains room name passed in request
private java.lang.String getPlayersInGame(java.lang.String id)
id
- Idicates for which request reply will be produced
private java.lang.String newRoom(java.lang.String id, org.jdom.Element name, org.jdom.Element type) throws DbWrapperException
id
- Idicates for which request reply will be producedname
- Node which contains room name to create passed in requesttype
- Node which contains room type (public or private) passed in
request
DbWrapperException
private java.lang.String removeRoom(java.lang.String id, org.jdom.Element name) throws DbWrapperException
id
- Idicates for which request reply will be producedname
- Node which contains room name to remove passed in request
DbWrapperException
private java.lang.String getStats(java.lang.String id)
id
- Idicates for which request reply will be produced *
private java.lang.String replyOK(java.lang.String id, java.lang.String type)
id
- Idicates for which request reply will be producedtype
- Type of request for which reply will be generated
private java.lang.String replyFailed(java.lang.String id, java.lang.String type, java.lang.String reason)
id
- Idicates for which request reply will be producedtype
- Type of request for which reply will be generatedreason
- Reason why failure occured
private java.lang.String reply(java.lang.String id, java.lang.String type, java.lang.String content)
id
- type
- content
-
private java.lang.String broadcastInRoom(java.lang.String type, java.lang.String content)
type
- Which type of request caused this broadcast
private java.lang.String broadcastInGame(java.lang.String type, java.lang.String name)
type
- Which type of request caused this broadcastname
- What name node will contain
private java.lang.String broadcastChatMsg(java.lang.String from, java.lang.String msg)
from
- Name of user who sends this messagemsg
- Message to send
private java.lang.String sendInvitation(java.lang.String roomName, java.lang.String to)
roomName
-
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |