Package net.sf.colossus.webserver
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 int
Client side versionprivate final WebServerClientSocketThread
The client socket thread that handled the low-level connection stuffprivate long
Time when last gameStartsNowSent was sent (in ms since epoch)private long
Time when last gameStartsSoonSent was sent (in ms since epoch)private boolean
Whether or not this WebServerClient is at the moment logged inprivate static final Logger
private static final String
private WebServer
The web server object that is managing all WebServerClientsprivate String
During registration request and sending of confirmation code, we do not have a user yet.private User
The user associated with this WebClient connectionFields inherited from interface net.sf.colossus.webcommon.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 TypeMethodDescriptionvoid
chatDeliver
(String chatId, long when, String sender, String message, boolean resent) void
connectionReset
(boolean forcedLogout) void
deliverGeneralMessage
(long when, boolean error, String title, String message) void
void
didUnenroll
(String gameId, String username) private String
ensureNotAlreadyLoggedIn
(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.void
gameCancelled
(String gameId, String byUser) void
void
gameStartsNow
(String gameId, int port, String hostingHost) void
gameStartsSoon
(String gameId, String byUser) int
boolean
(package private) User
getUser()
(package private) String
void
void
boolean
void
processChatLine
(String chatId, String sender, String message) void
requestAttention
(long when, String byUser, boolean byAdmin, String message, int beepCount, long beepInterval, boolean windows) void
requestPing
(String arg1, String arg2, String arg3) void
requestPingIfNeeded
(long now) void
private void
private void
setClientVersion
(int version) void
setLoggedIn
(boolean val) void
setUnverifiedUsername
(String name) private void
void
void
systemMessage
(long now, String message) void
void
watchGameInfo
(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:
getClientVersion
in 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:
systemMessage
in interfaceIWebClient
-
sendToClient
-
grantAdminStatus
public void grantAdminStatus()- Specified by:
grantAdminStatus
in interfaceIWebClient
-
didEnroll
- Specified by:
didEnroll
in interfaceIWebClient
-
didUnenroll
- Specified by:
didUnenroll
in interfaceIWebClient
-
gameCancelled
- Specified by:
gameCancelled
in interfaceIWebClient
-
userInfo
- Specified by:
userInfo
in interfaceIWebClient
-
gameInfo
- Specified by:
gameInfo
in interfaceIWebClient
-
gameStartsSoon
- Specified by:
gameStartsSoon
in interfaceIWebClient
-
gameStartsNow
- Specified by:
gameStartsNow
in interfaceIWebClient
-
chatDeliver
- Specified by:
chatDeliver
in interfaceIWebClient
-
deliverGeneralMessage
- Specified by:
deliverGeneralMessage
in interfaceIWebClient
-
requestAttention
public void requestAttention(long when, String byUser, boolean byAdmin, String message, int beepCount, long beepInterval, boolean windows) - Specified by:
requestAttention
in interfaceIWebClient
-
watchGameInfo
- Specified by:
watchGameInfo
in interfaceIWebClient
-
requestPing
-
connectionReset
public void connectionReset(boolean forcedLogout) - Specified by:
connectionReset
in interfaceIWebClient
-