Package net.sf.colossus.webclient
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 class
class
Nested classes/interfaces inherited from class java.lang.Thread
Thread.State, Thread.UncaughtExceptionHandler
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate WebClientSocketThread.AckWaiter
private final Charset
private boolean
private static final Object
private static int
private static WebClientSocketThread
private String
private boolean
private String
private BufferedReader
private boolean
private static final Logger
private PrintWriter
private String
private final int
private static final String
private Socket
private boolean
private String
private IWebClient
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
Fields inherited from interface net.sf.colossus.webcommon.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 void
void
cancelGame
(String gameId, String byUser) void
chatSubmit
(String chatId, String sender, String message) private void
private void
Send the confirmation codevoid
confirmCommand
(String cmd, String arg1, String arg2, String arg3) private void
connect()
void
dispose()
private void
void
dumpInfo()
void
enrollUserToGame
(String gameId, String username) private void
handleAckNack
(String command, String[] tokens) void
informLocallyGameOver
(String gameId) void
informStartedByPlayer
(String gameId) private void
login()
void
logout()
void
pingResponse
(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 void
register()
Initial registration attemptvoid
requestUserAttention
(long when, String sender, boolean isAdmin, String recipient, String message, int beepCount, long beepInterval, boolean windows) void
private GameInfo
restoreGameInfo
(String[] tokens) void
run()
private void
void
void
sleepFor
(long millis) void
void
startGameOnPlayerHost
(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.boolean
void
submitAnyText
(String text) void
unenrollUserFromGame
(String gameId, String username) void
private void
Methods inherited from class java.lang.Thread
activeCount, checkAccess, clone, countStackFrames, currentThread, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, onSpinWait, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, suspend, 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
public void run() -
restoreGameInfo
-
doCleanup
private void doCleanup() -
dispose
public void dispose() -
send
-
logout
public void logout()- Specified by:
logout
in interfaceIWebServer
-
changeProperties
public String changeProperties(String username, String oldPW, String newPW, String email, Boolean isAdminObj) - Specified by:
changeProperties
in 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:
proposeGame
in interfaceIWebServer
-
enrollUserToGame
- Specified by:
enrollUserToGame
in interfaceIWebServer
-
unenrollUserFromGame
- Specified by:
unenrollUserFromGame
in interfaceIWebServer
-
cancelGame
- Specified by:
cancelGame
in interfaceIWebServer
-
startGame
- Specified by:
startGame
in interfaceIWebServer
-
informStartedByPlayer
- Specified by:
informStartedByPlayer
in interfaceIWebServer
-
informLocallyGameOver
- Specified by:
informLocallyGameOver
in interfaceIWebServer
-
startGameOnPlayerHost
Description copied from interface:IWebServer
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.- Specified by:
startGameOnPlayerHost
in interfaceIWebServer
-
chatSubmit
- Specified by:
chatSubmit
in interfaceIWebServer
-
pingResponse
-
watchGame
- Specified by:
watchGame
in 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:
requestUserAttention
in interfaceIWebServer
-
shutdownServer
public void shutdownServer()- Specified by:
shutdownServer
in interfaceIWebServer
-
rereadLoginMessage
public void rereadLoginMessage()- Specified by:
rereadLoginMessage
in interfaceIWebServer
-
dumpInfo
public void dumpInfo()- Specified by:
dumpInfo
in interfaceIWebServer
-
submitAnyText
-
writeLog
-