Class WebClientSocketThread
java.lang.Object
java.lang.Thread
net.sf.colossus.webclient.WebClientSocketThread
- All Implemented Interfaces:
Runnable, IWebServer
This implements the webserver/client communication at client side.
It implements the server interface on client side;
i.e. something server wanted to execute for a client, is read
from the client socket input stream, parsed, and executed
by the (WebClient)SocketThread.
This also contains the methods which are called by the client
(WebClient's GUI) and are sent over the socket to the server
(note that those calls mostly happen in the EDT).
- Author:
- Clemens Katzer
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate classclassNested classes/interfaces inherited from class Thread
Thread.Builder, Thread.State, Thread.UncaughtExceptionHandler -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate WebClientSocketThread.AckWaiterprivate final Charsetprivate booleanprivate static final Objectprivate static intprivate static WebClientSocketThreadprivate Stringprivate booleanprivate Stringprivate BufferedReaderprivate booleanprivate static final Loggerprivate PrintWriterprivate Stringprivate final intprivate static final Stringprivate Socketprivate booleanprivate Stringprivate IWebClientFields inherited from class Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITYFields inherited from interface IWebServer
Cancel, ChangePassword, ChatSubmit, ConfirmCommand, ConfirmRegistration, DumpInfo, Echo, Enroll, generalChatName, LocallyGameOver, Login, Logout, PingResponse, Propose, RegisterUser, RequestUserAttention, RereadLoginMessage, ShutdownServer, Start, StartAtPlayer, StartedByPlayer, Unenroll, WatchGame, WebProtocolSeparator -
Constructor Summary
ConstructorsConstructorDescriptionWebClientSocketThread(IWebClient wcGUI, String hostname, int port, String username, String password, boolean force, String email, String confCode, HashMap<String, GameInfo> gameHash) -
Method Summary
Modifier and TypeMethodDescriptionstatic voidvoidcancelGame(String gameId, String byUser) voidchatSubmit(String chatId, String sender, String message) private voidprivate voidSend the confirmation codevoidconfirmCommand(String cmd, String arg1, String arg2, String arg3) private voidconnect()voiddispose()private voidvoiddumpInfo()voidenrollUserToGame(String gameId, String username) private voidhandleAckNack(String command, String[] tokens) voidinformLocallyGameOver(String gameId) voidinformStartedByPlayer(String gameId) private voidlogin()voidlogout()voidpingResponse(String arg1, String arg2, String arg3) proposeGame(String initiator, String variant, String viewmode, long startAt, int duration, String summary, String expire, boolean unlimitedMulligans, boolean balancedTowers, int min, int target, int max) private voidregister()Initial registration attemptvoidrequestUserAttention(long when, String sender, boolean isAdmin, String recipient, String message, int beepCount, long beepInterval, boolean windows) voidprivate GameInforestoreGameInfo(String[] tokens) voidrun()private voidvoidvoidsleepFor(long millis) voidvoidstartGameOnPlayerHost(String gameId, String hostingPlayer, String playerHost, int port) A game was started by a WebClient user locally on his computer and is ready to accept the other players as remote client; so we notify them and tell them host and port to where to connect.booleanvoidsubmitAnyText(String text) voidunenrollUserFromGame(String gameId, String username) voidprivate voidMethods inherited from class Thread
activeCount, checkAccess, clone, currentThread, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, isVirtual, join, join, join, join, ofPlatform, ofVirtual, onSpinWait, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, sleep, start, startVirtualThread, stop, threadId, toString, yield
-
Field Details
-
LOGGER
-
webClient
-
gameHash
-
hostname
-
port
private final int port -
username
-
password
-
force
private boolean force -
email
-
socket
-
in
-
out
-
stillNeedsRun
private boolean stillNeedsRun -
sep
- See Also:
-
loggedIn
private boolean loggedIn -
ackWaiter
-
failedException
-
counter
private static int counter -
currentAttempt
-
closingForcefullyToCancel
private boolean closingForcefullyToCancel -
connectOngoingMutex
-
charset
-
-
Constructor Details
-
WebClientSocketThread
-
-
Method Details
-
getOneLine
- Throws:
IOException
-
getException
-
cancelConnectAttempt
public static void cancelConnectAttempt() -
closeSocketForcefully
private void closeSocketForcefully() -
connect
-
register
Initial registration attempt -
confirm
Send the confirmation code -
login
-
stillNeedsRun
public boolean stillNeedsRun() -
getUsername
-
run
-
restoreGameInfo
-
doCleanup
private void doCleanup() -
dispose
public void dispose() -
send
-
logout
public void logout()- Specified by:
logoutin interfaceIWebServer
-
changeProperties
public String changeProperties(String username, String oldPW, String newPW, String email, Boolean isAdminObj) - Specified by:
changePropertiesin interfaceIWebServer
-
handleAckNack
-
proposeGame
public GameInfo proposeGame(String initiator, String variant, String viewmode, long startAt, int duration, String summary, String expire, boolean unlimitedMulligans, boolean balancedTowers, int min, int target, int max) - Specified by:
proposeGamein interfaceIWebServer
-
enrollUserToGame
- Specified by:
enrollUserToGamein interfaceIWebServer
-
unenrollUserFromGame
- Specified by:
unenrollUserFromGamein interfaceIWebServer
-
cancelGame
- Specified by:
cancelGamein interfaceIWebServer
-
startGame
- Specified by:
startGamein interfaceIWebServer
-
informStartedByPlayer
- Specified by:
informStartedByPlayerin interfaceIWebServer
-
informLocallyGameOver
- Specified by:
informLocallyGameOverin interfaceIWebServer
-
startGameOnPlayerHost
Description copied from interface:IWebServerA game was started by a WebClient user locally on his computer and is ready to accept the other players as remote client; so we notify them and tell them host and port to where to connect.- Specified by:
startGameOnPlayerHostin interfaceIWebServer
-
chatSubmit
- Specified by:
chatSubmitin interfaceIWebServer
-
pingResponse
-
watchGame
- Specified by:
watchGamein interfaceIWebServer
-
sleepFor
public void sleepFor(long millis) -
confirmCommand
-
requestUserAttention
public void requestUserAttention(long when, String sender, boolean isAdmin, String recipient, String message, int beepCount, long beepInterval, boolean windows) - Specified by:
requestUserAttentionin interfaceIWebServer
-
shutdownServer
public void shutdownServer()- Specified by:
shutdownServerin interfaceIWebServer
-
rereadLoginMessage
public void rereadLoginMessage()- Specified by:
rereadLoginMessagein interfaceIWebServer
-
dumpInfo
public void dumpInfo()- Specified by:
dumpInfoin interfaceIWebServer
-
submitAnyText
-
writeLog
-