Package net.sf.colossus.webclient
Class CmdLineWebClient
java.lang.Object
net.sf.colossus.webclient.CmdLineWebClient
- All Implemented Interfaces:
IWebClient
A first start to create a cmdline WebClient. For example for automated
testing or for shutting down the server.
Still "Work in Progress", just committing it to get my work copy clean...
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final String
private static final String
NOTE: shared with SocketThread, because WCST needs it to restore game tokens to an GameInfo objectprivate final String
private static final Logger
private final int
private IWebServer
private WebClientSocketThread
Fields 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) void
gameCancelled
(String gameId, String byUser) void
void
gameStartsNow
(String gameId, int port, String hostingHost) void
gameStartsSoon
(String gameId, String byUser) int
private static String
private String
void
private static void
interactiveLoop
(CmdLineWebClient cwClient) private boolean
Create a commandline client (CmdLineWebClient) and login with given parametersprivate boolean
logout()
Logout the active CmdlineClientstatic void
void
requestAttention
(long when, String byUser, boolean byAdmin, String message, int beepCount, long beepInterval, boolean windows) private void
private static void
sleepFor
(long millis) void
systemMessage
(long when, String message) private void
typedInChat
(String message) void
updateStatus
(String text, Color color) void
void
watchGameInfo
(String gameId, String host, int port)
-
Field Details
-
LOGGER
-
DEFAULT_USERNAME
- See Also:
-
DEFAULT_PASSWORD
- See Also:
-
server
-
wcst
-
hostname
- See Also:
-
port
private final int port- See Also:
-
gameHash
NOTE: shared with SocketThread, because WCST needs it to restore game tokens to an GameInfo object
-
-
Constructor Details
-
CmdLineWebClient
public CmdLineWebClient()
-
-
Method Details
-
getClientVersion
public int getClientVersion()- Specified by:
getClientVersion
in interfaceIWebClient
-
main
- Parameters:
args
-
-
interactiveLoop
-
getOneLineFromStdin
- Throws:
IOException
-
sleepFor
private static void sleepFor(long millis) -
login
Create a commandline client (CmdLineWebClient) and login with given parameters- Parameters:
force
-username
-password
-- Returns:
-
logout
private boolean logout()Logout the active CmdlineClient- Returns:
-
isLoggedIn
private boolean isLoggedIn() -
getUsername
-
shutdownServer
private void shutdownServer() -
typedInChat
-
updateStatus
-
chatDeliver
- Specified by:
chatDeliver
in interfaceIWebClient
-
deliverGeneralMessage
- Specified by:
deliverGeneralMessage
in interfaceIWebClient
-
systemMessage
- Specified by:
systemMessage
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
-
connectionReset
public void connectionReset(boolean forcedLogout) - Specified by:
connectionReset
in interfaceIWebClient
-
didEnroll
- Specified by:
didEnroll
in interfaceIWebClient
-
didUnenroll
- Specified by:
didUnenroll
in interfaceIWebClient
-
gameCancelled
- Specified by:
gameCancelled
in interfaceIWebClient
-
gameInfo
- Specified by:
gameInfo
in interfaceIWebClient
-
gameStartsNow
- Specified by:
gameStartsNow
in interfaceIWebClient
-
gameStartsSoon
- Specified by:
gameStartsSoon
in interfaceIWebClient
-
grantAdminStatus
public void grantAdminStatus()- Specified by:
grantAdminStatus
in interfaceIWebClient
-
userInfo
- Specified by:
userInfo
in interfaceIWebClient
-
watchGameInfo
- Specified by:
watchGameInfo
in interfaceIWebClient
-