Class WebServerClient
java.lang.Object
net.sf.colossus.webserver.WebServerClient
- All Implemented Interfaces:
IWebClient
This class represents an actual WebServer client.
Mostly it contains the client's state data (logged in, client version,
user and user name, and such).
It holds the reference to the actual socket thread that is waiting
for input from client.
This class here provides the parsing of commands coming from clients
to convert them into actual calls to to on the server object, and it
also provides the methods which the server calls on the client
(=translates method calls into text to send them over the socket).
TODO:
The "parse messages" still contains some blocks and processing
which should rather be in the actual socket thread object
(during split into client and actual socket thread just copied the
whole if-elseif-else block to here).
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate intClient side versionprivate final WebServerClientSocketThreadThe client socket thread that handled the low-level connection stuffprivate longTime when last gameStartsNowSent was sent (in ms since epoch)private longTime when last gameStartsSoonSent was sent (in ms since epoch)private booleanWhether or not this WebServerClient is at the moment logged inprivate static final Loggerprivate static final Stringprivate WebServerThe web server object that is managing all WebServerClientsprivate StringDuring registration request and sending of confirmation code, we do not have a user yet.private UserThe user associated with this WebClient connectionFields inherited from interface IWebClient
alreadyLoggedIn, chatDeliver, connectionClosed, didEnroll, didUnenroll, forcedLogout, gameCancelled, gameInfo, gameStarted, gameStartsNow, gameStartsSoon, generalMessage, grantAdmin, pingRequest, requestAttention, systemMessage, tooManyUsers, userInfo, watchGameInfo -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidchatDeliver(String chatId, long when, String sender, String message, boolean resent) voidconnectionReset(boolean forcedLogout) voiddeliverGeneralMessage(long when, boolean error, String title, String message) voidvoiddidUnenroll(String gameId, String username) private StringensureNotAlreadyLoggedIn(String username, boolean force) if password is okay, check first whether same user is already logged in with another connection; if yes, when force is not set (1st try), send back the "already logged in"; reacting on that, client will prompt whether to force the old connection out, and if user answers yes, will send a 2nd login message, this time with force flag set.voidgameCancelled(String gameId, String byUser) voidvoidgameStartsNow(String gameId, int port, String hostingHost) voidgameStartsSoon(String gameId, String byUser) intboolean(package private) UsergetUser()(package private) StringvoidvoidbooleanvoidprocessChatLine(String chatId, String sender, String message) voidrequestAttention(long when, String byUser, boolean byAdmin, String message, int beepCount, long beepInterval, boolean windows) voidrequestPing(String arg1, String arg2, String arg3) voidrequestPingIfNeeded(long now) voidprivate voidprivate voidsetClientVersion(int version) voidsetLoggedIn(boolean val) voidsetUnverifiedUsername(String name) private voidvoidvoidsystemMessage(long now, String message) voidvoidwatchGameInfo(String gameId, String host, int port)
-
Field Details
-
LOGGER
-
sep
- See Also:
-
cst
The client socket thread that handled the low-level connection stuff -
server
The web server object that is managing all WebServerClients -
loggedIn
private boolean loggedInWhether or not this WebServerClient is at the moment logged in -
clientVersion
private int clientVersionClient side version -
user
The user associated with this WebClient connection -
unverifiedUsername
During registration request and sending of confirmation code, we do not have a user yet. The parseLine sets then this variable according to the username argument which was send from client. -
gameStartsNowSent
private long gameStartsNowSentTime when last gameStartsNowSent was sent (in ms since epoch) -
gameStartsSoonSent
private long gameStartsSoonSentTime when last gameStartsSoonSent was sent (in ms since epoch)
-
-
Constructor Details
-
WebServerClient
-
-
Method Details
-
startThread
public void startThread() -
getWSCSThread
-
setClientVersion
private void setClientVersion(int version) -
getClientVersion
public int getClientVersion()- Specified by:
getClientVersionin interfaceIWebClient
-
setUser
-
getUser
User getUser() -
getUsername
String getUsername() -
setUnverifiedUsername
-
getUnverifiedUsername
-
requestPingIfNeeded
public void requestPingIfNeeded(long now) -
requestPingNow
public void requestPingNow() -
setLoggedIn
public void setLoggedIn(boolean val) -
getLoggedIn
public boolean getLoggedIn() -
handleLogout
public void handleLogout() -
parseLine
-
makeCaseMismatchWarning
-
processChatLine
-
ensureNotAlreadyLoggedIn
if password is okay, check first whether same user is already logged in with another connection; if yes, when force is not set (1st try), send back the "already logged in"; reacting on that, client will prompt whether to force the old connection out, and if user answers yes, will send a 2nd login message, this time with force flag set. -
systemMessage
- Specified by:
systemMessagein interfaceIWebClient
-
sendToClient
-
grantAdminStatus
public void grantAdminStatus()- Specified by:
grantAdminStatusin interfaceIWebClient
-
didEnroll
- Specified by:
didEnrollin interfaceIWebClient
-
didUnenroll
- Specified by:
didUnenrollin interfaceIWebClient
-
gameCancelled
- Specified by:
gameCancelledin interfaceIWebClient
-
userInfo
- Specified by:
userInfoin interfaceIWebClient
-
gameInfo
- Specified by:
gameInfoin interfaceIWebClient
-
gameStartsSoon
- Specified by:
gameStartsSoonin interfaceIWebClient
-
gameStartsNow
- Specified by:
gameStartsNowin interfaceIWebClient
-
chatDeliver
- Specified by:
chatDeliverin interfaceIWebClient
-
deliverGeneralMessage
- Specified by:
deliverGeneralMessagein interfaceIWebClient
-
requestAttention
public void requestAttention(long when, String byUser, boolean byAdmin, String message, int beepCount, long beepInterval, boolean windows) - Specified by:
requestAttentionin interfaceIWebClient
-
watchGameInfo
- Specified by:
watchGameInfoin interfaceIWebClient
-
requestPing
-
connectionReset
public void connectionReset(boolean forcedLogout) - Specified by:
connectionResetin interfaceIWebClient
-